自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

小木匠QvQ

此鸟不飞则已 一飞冲天 不鸣则已 一鸣惊人 我要做这只鸟儿!

  • 博客(89)
  • 收藏
  • 关注

原创 01-复杂度1 最大子列和问题(20 分)

import java.util.Scanner;import static java.lang.Math.*;public class Main { /** * O(n) algorithm. */ public static int longestSubsequence1(int[] p, int n) { int thisSum = 0; int maxSum =

2017-10-03 19:16:25 287

原创 1056. Mice and Rice (25)

Mice and Rice is the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice

2017-08-02 16:46:53 297

原创 1055. The World's Richest (25)

Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the peopl

2017-07-31 21:14:14 304

原创 1053. Path of Equal Weight (30)

Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to Lis defined to be the sum of the weights of all the nodes along the path from R t

2017-07-31 17:22:23 214

原创 1047. Student List for Course (25)

Zhejiang University has 40000 students and provides 2500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input S

2017-07-30 14:40:38 200

原创 1039. Course List for Student (25)

Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes

2017-07-29 14:40:41 210

原创 1046. Shortest Distance (20)

The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input file c

2017-07-29 11:18:54 219

原创 1045. Favorite Color Stripe (30)

Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pieces and sewing the remaining parts

2017-07-29 00:35:39 184

原创 PAT 1044 Shopping in Mars(25)

Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any position

2017-07-28 16:07:56 251

原创 PAT题目分类

树:1043(判断给定序列是否为BST或镜像BST的先序序列,如是,给出相应的后序序列)

2017-07-28 11:03:59 278

原创 PAT 1043. Is It a Binary Search Tree (25)

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.The righ

2017-07-28 11:00:16 190

原创 第十三周作业:冷血格斗场

总时间限制: 1000ms 内存限制: 65536kB描述为了迎接08年的奥运会,让大家更加了解各种格斗运动,facer新开了一家冷血格斗场。格斗场实行会员制,但是新来的会员不需要交入会费,而只要同一名老会员打一场表演赛,证明自己的实力。我们假设格斗的实力可以用一个正整数表示,成为实力值,两人的实力值可以相同。另外,每个人都有一个唯一的id,也是一个正整数。为了使得比赛

2017-04-30 11:07:15 806

原创 第十二章 set和multiset

set和multiset插入,删除,查找都是O(log n)复杂度的。 set不允许重复 multiset则允许。#include "iostream"#include "map"#include "set"using namespace std;int main() { multisetst; int a[10] = { 1,14,12,13,7,13,21,19,8,8 };

2017-04-28 17:24:41 319

原创 第十一章 算法的时间复杂度

1:派总时间限制: 1000ms 内存限制: 65536kB描述我的生日要到了!根据习俗,我需要将一些派分给大家。我有N个不同口味、不同大小的派。有F个朋友会来参加我的派对,每个人会拿到一块派(必须一个派的一块,不能由几个派的小块拼成;可以是一整个派)。我的朋友们都特别小气,如果有人拿到更大的一块,就会开始抱怨。因此所有人拿到的派是同样大小的(但不需要是

2017-04-26 17:20:54 430

转载 [OS] 操作系统常考知识点

转载自:http://www.cnblogs.com/lca1826/p/6604695.html大纲如下:1.操作系统概述2.操作系统运行环境3.进程线程模型4.处理器调度5.同步机制6.存储模型7.文件系统8.I/O系统9.死锁 ·操作系统概述1.执行程序:通过调度选中程序开始执行,在执行过程中,不断陷入操作系统提供各种服务支持,再调度选中程

2017-03-31 17:55:37 576

原创 第十章

1:成绩排序总时间限制: 1000ms 内存限制: 65536kB描述给出班里某门课程的成绩单,请你按成绩从高到低对成绩单排序输出,如果有相同分数则名字字典序小的在前。输入第一行为n (0 接下来的n行,每行为每个学生的名字和他的成绩, 中间用单个空格隔开。名字只包含字母且长度不超过20,成绩为一个不大于100的非负整数。输出把成绩单按分数从高到

2017-03-29 23:23:36 2678

原创 1054. The Dominant Color (20)

Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the d

2017-03-29 10:20:55 315

原创 第七章 深度优先搜索(dfs+可行性剪枝)

1:红与黑总时间限制: 1000ms 内存限制: 65536kB描述有一间长方形的房子,地上铺了红色、黑色两种颜色的正方形瓷砖。你站在其中一块黑色的瓷砖上,只能向相邻的黑色瓷砖移动。请写一个程序,计算你总共能够到达多少块黑色的瓷砖。输入包括多个数据集合。每个数据集合的第一行是两个整数W和H,分别表示x方向和y方向瓷砖的数量。W和H都不超过20。在接下来的H行中,每行

2017-03-27 22:06:17 834

原创 第八章 深度优先搜索(dfs+可行性剪枝+最优性剪枝)

1:鸣人和佐助总时间限制: 1000ms 内存限制: 65536kB描述佐助被大蛇丸诱骗走了,鸣人在多少时间内能追上他呢?已知一张地图(以二维矩阵的形式表示)以及佐助和鸣人的位置。地图上的每个位置都可以走到,只不过有些位置上有大蛇丸的手下,需要先打败大蛇丸的手下才能到这些位置。鸣人有一定数量的查克拉,每一个单位的查克拉可以打败一个大蛇丸的手下。假设鸣人可以往上下左右

2017-03-27 19:29:21 1920

原创 04-树5 Root of AVL Tree (25分)

An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is

2017-03-26 14:17:14 383

原创 随笔

最近才发现“吾日三省吾身”这句话真的很有道理。历史书,古人的智慧还是值得去看的。 1.  每一天,希望每天睡觉之前,都可以反思自己今天做了什么,收获了什么。如果发现自己今天什么都没有收获,那么今天的你和昨天的你就没有区别。如果你收获一些东西,那么你就是进步的~ 如果每一天的你都是进步的,有一天你就会是优秀的~ (量变产生质变 所以说坚持是多么宝贵的事情)2. 科学的给自己制定计划。 有了计

2017-03-26 10:35:44 206

原创 04-树6 Complete Binary Search Tree (30分)

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node's key.

2017-03-26 10:14:59 263

原创 04-树4 是否同一棵二叉搜索树 (25分)

给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。输入格式:输入包含若干组测试数据。每组数据的第1行给出两个正整数NN (\le 10≤10)和LL,分别是每

2017-03-25 20:20:05 322

原创 04-树7 二叉搜索树的操作集 (30分)

本题要求实现给定二叉搜索树的5种常用操作。函数接口定义:BinTree Insert( BinTree BST, ElementType X );BinTree Delete( BinTree BST, ElementType X );Position Find( BinTree BST, ElementType X );Position FindMin( BinTree BST

2017-03-25 19:35:12 1990

原创 第五章 问题的模块化求解

其实就是讲函数。。也没啥好讲的注意几个传递是重点: 值传递 指针传递 引用传递 。 其它的基本看过谭浩强C的都应该掌握的挺好的。。几个习题 我也没刻意的写成函数。。 完全当成了字符串处理练习。。额。。老师 别打我。。。1.编写字符串反转函数mystrrev,该函数的功能是将指定字符串中的字符顺序颠倒(前变后,后变前)。然后再编写主函数验证之。注意,输入输出应在主函数中进行。/*

2017-03-24 00:23:25 873

原创 第六章 递归,内联,重载,作用域和存储类型

其实西安交大的老师们 上课没什么趣味性,开始听着挺不习惯的。 但是老师们人真的都很好,问的问题基本都认真帮忙解答的~很热心~还是点个赞递归还是很简单,毕竟搞了很多题目了。内联。。讲实话  写代码的时候 基本没用过inline。。 不过可以提高程序运行效率 这主要是因为调用函数要搞个栈保存函数返回地址等等 调用结束 恢复现场 浪费空间 ,时间而内联则是 直接把代码块复制过来 没有上述操作

2017-03-23 23:36:31 513

原创 第九章 广度优先搜索

1:迷宫问题定义一个二维数组: int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线

2017-03-23 11:19:05 296

原创 Lambada表达式

Java8以后引入的。Lambada表达式(λ expression)写法:(参数)-> 结果在Java中 它实际上相当于匿名类的一个实例(把匿名类写的更简洁 接口,接口函数的简写)例子:import java.util.Arrays;public class SortTest { public static void main(String[] args) { /

2017-03-22 12:51:57 550

原创 内部类和匿名类

内部类:编译器生成XXXX$XXXX这样的class文件使用1.类名前要加以外部类的名字2.使用new创建内部类时,也要在new前面冠以对象变量public class TestInnerClass { public static void main(String[] args) { Parcel p = new Parcel(); p.testShi

2017-03-22 11:58:41 327

原创 对象构造与初始化

构造方法:1.对象都有构造方法2.如果没有,编译器添加一个default构造方法。抽象类也有构造方法,而且他的子类也会调它的构造方法。调用本类或者父类的构造方法this调用本类的构造方法,super调用父类的构造方法。(this,super要放在第一条语句,并且最多只能有一条)所有父类的构造方法必须都得到调用 否则对象的构建就不正确public class Constr

2017-03-22 10:01:31 245

原创 多态和虚方法调用

多态:1.编译时的多态   函数重载2. 运行时多态  1.覆盖 子类override父类的方法  2.动态绑定(dynamic binding) - - 虚方法调用(virtual method invoking)父类引用指向子类对象。多态大大地提高了程序的抽象程度和简洁性。面向对象的三大特性:封装,继承和多态。(哈哈 )所有非final方法都会自动地进行动态绑定

2017-03-21 22:24:32 1396

原创 变量及其传递

基本类型:其值直接存于变量中。引用类型:除占据一定内存空间外,它所引用的对象实体(由new创建)也要占用一定的内存空间(我的理解是差不多就是C++创建了个变量  然后又搞了个指针指向它。。)package com.pku.edu.ch5;public class MyDate { private int day; private int month; private int ye

2017-03-21 18:56:52 597

原创 第八,九章

这一章主要讲了字符串操作库函数 其中以前没太知道的strtok字符串分隔函数(很有用。) strchr(查找第一个字符出现的位置) strncat,strncpy等等。然后介绍了指针 (包括了void*指针(以前我都不知道有着玩意。。超级有用)指向函数的指针(以前觉得根本没啥用。。现在发现真是有大用处。。都想看看侯杰的书,自己实现一部分STL的功能了。。))还有memset为什么不能赋值整

2017-03-21 12:36:36 316

原创 PAT 1038. Recover the Smallest Number (30)

Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 87}, we can recover many numbers such like 32-321-3214-0229-8

2017-03-20 18:16:15 192

原创 PAT 1037. Magic Coupon (25)

The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product b

2017-03-20 16:34:01 172

原创 PAT 1093. Count PAT's (25)

The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.No

2017-03-20 15:42:35 247

原创 PAT 1042. Shuffling Machine (20)

Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gambler

2017-03-20 12:09:59 216

原创 PAT 1059. Prime Factors (25)

Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1 * p2^k2 *…*pm^km.Input Specification:Each input file contains one test c

2017-03-20 09:15:21 289

原创 PAT 1041. Be Unique (20)

Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1, 104]. The first one who bets on

2017-03-19 23:10:37 177

原创 PAT 1036 Boys vs Girls (25)

This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contains o

2017-03-19 21:00:50 377

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除