自定义博客皮肤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)
  • 收藏
  • 关注

原创 PAT 1035 1035. Password (20)

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L

2017-03-19 20:30:30 465

原创 03-树3 Tree Traversals Again (25分)

An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac

2017-03-18 18:34:54 298

原创 03-树2 List Leaves (25分)

Given a tree, you are supposed to list all the leaves in the order of top down, and left to right.Input Specification:Each input file contains one test case. For each case, the first line give

2017-03-18 12:30:06 288

原创 03-树1 树的同构 (25分)

给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。图1图2现给定两棵树,请你判断它们是否是同构的。输入格式:输入给出2棵二叉树树的信息。对于每棵树

2017-03-18 11:38:58 240

原创 PAT 1032. Sharing (25)

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,

2017-03-17 22:43:15 207

原创 PAT 1031. Hello World for U (20)

Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as:h de ll rlowoThat is, the characters must be pr

2017-03-17 19:08:11 244

原创 C++ string中的erase函数

编写函数去除字符串中包含的非字母字符(不包括空格),并将小写字母转换成大写字母。注意,不在函数中输出。输入输出应在主函数中进行。输入格式:待转换的字符串,字符串间会包含空格,长度不超过200。输出格式:转换后的字符串输入样例:happy new year!输出样例:

2017-03-16 18:29:45 977

原创 PAT 1030. Travel Plan (30)

A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path b

2017-03-15 15:50:23 262

原创 PAT 1028. List Sorting (25)

Excel can sort records according to any column. Now you are supposed to imitate this function.InputEach input file contains one test case. For each case, the first line contains two integers N

2017-03-14 17:14:16 219

原创 PAT 1029. Median (25)

Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16, 17} is 15. The

2017-03-14 13:49:27 221

原创 PAT 1025. PAT Ranking (25)

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists w

2017-03-14 11:45:52 227

原创 PAT 1024. Palindromic Number (25)

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers

2017-03-14 10:04:55 306

原创 PAT 1023. Have Fun with Numbers (20)

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con

2017-03-13 14:38:25 253

原创 PAT 1027. Colors in Mars (20)

People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 dig

2017-03-13 13:08:47 216

原创 PAT 1019 General Palindromic Number (20)

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers

2017-03-12 20:29:33 247

原创 02-线性结构4 Pop Sequence (25分) (栈)

Given a stack which can keep MM numbers at most. Push NN numbers in the order of 1, 2, 3, ..., NN and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequ

2017-03-09 14:40:20 265

原创 02-线性结构3 Reversing Linked List (25分)

Given a constant KK and a singly linked list LL, you are supposed to reverse the links of every KK elements on LL. For example, given LL being 1→2→3→4→5→6, if K = 3K=3, then you must outpu

2017-03-09 13:58:08 248

原创 02-线性结构1 两个有序链表序列的合并 (15分) (单向链表)

本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列。函数接口定义:List Merge( List L1, List L2 );其中List结构定义如下:typedef struct Node *PtrToNode;struct Node { ElementType Data; /* 存储结点数据 */ PtrToNode

2017-03-08 21:34:38 987

原创 5-2 一元多项式的乘法与加法运算 (20分) (单向链表)

设计函数分别求两个一元多项式的乘积与和。输入格式:输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应输出0 0。输入样例:

2017-03-08 19:08:36 392

原创 插入加密

5插入加密(20分)题目内容:插入式加密是在明文字母中按照指定间隔插入另一些字母以形成密文。例如对明文china,在间隔为1的位置插入其它字母序列中的字母a,b,c,d,e,就变成密文cahbicndae;间隔为2时的密文为chainbac,要求输入明文和间隔,从存放其它字母的序列(仅包含a,b,c,d,e)中依次取出对应字母插入到明文中,如果其它字母序列的字母取完

2017-03-08 14:54:17 2413

原创 OpenJudge 4:最长最短单词

总时间限制: 1000ms 内存限制: 65536kB描述输入1行句子(不多于200个单词,每个单词长度不超过100),只包含字母、空格和逗号。单词由至少一个连续的字母构成,空格和逗号都是单词间的间隔。试输出第1个最长的单词和第1个最短单词。 输入一行句子。输出两行输出:第1行,第一个最长的单词。第2行,第一个最短的单词。样例输入I am

2017-03-07 13:58:08 2916

原创 OpenJudge-Mooc 1:红与黑

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

2017-03-07 10:57:50 562

原创 OpenJudge-Mooc 2:A Knight's Journey(dfs)

总时间限制: 1000ms 内存限制: 65536kB描述BackgroundThe knight is getting bored of seeing the same black and white squares again and again and has decided to make a journeyaround the world. Whenever a kn

2017-03-07 10:53:43 274

原创 OpenJudge-Mooc 323:棋盘问题(dfs)

总时间限制: 1000ms 内存限制: 65536kB描述在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。输入输入含有多组测试数据。每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及

2017-03-07 10:52:32 824 1

原创 浙大PAT 1021. Deepest Root (25)

A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed to find the root that results in a highest tree. Such a root

2017-03-05 13:55:42 264

原创 浙大PAT 1020. Tree Traversals (25)

Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor

2017-03-04 23:05:29 286

原创 OpenJudge-Mooc 2:拨钟问题

描述有9个时钟,排成一个3*3的矩阵。|-------| |-------| |-------|| | | | | | ||---O | |---O | | O || | | | | ||-------| |-------| |

2017-03-03 20:13:50 779

原创 OpenJudge-Mooc 1:特殊密码锁

总时间限制: 1000ms 内存限制: 1024kB描述有一种特殊的二进制密码锁,由n个相连的按钮组成(n然而让人头疼的是,当你按一个按钮时,跟它相邻的两个按钮状态也会反转。当然,如果你按的是最左或者最右边的按钮,该按钮只会影响到跟它相邻的一个按钮。当前密码锁状态已知,需要解决的问题是,你至少需要按多少次按钮,才能将密码锁转变为所期望的目标状态。输入

2017-03-03 15:25:54 965

原创 Openjudge-noi 2985 数字组合

总时间限制: 1000ms 内存限制: 65536kB描述有n个正整数,找出其中和为t(t也是正整数)的可能的组合方式。如:n=5,5个数分别为1,2,3,4,5,t=5;那么可能的组合有5=1+4和5=2+3和5=5三种组合方式。输入输入的第一行是两个正整数n和t,用空格隔开,其中1接下来的一行是n个正整数,用空格隔开。输出和为t的不同的组合方式的数目。样例输

2017-03-02 14:14:13 613

原创 Swust OJ 003 A Bug(判断图中是否有环)

Time limit(ms): 1000Memory limit(kb): 65535Submission: 406Accepted: 139Acceptedtest 判断图是否有环 并查集 bugBackground Professor Hopper is researching the sexual behavior of

2017-02-28 10:34:15 404

原创 Swust OJ 001 Satellite Photographs

Farmer John purchased satellite photos of W x H pixels of his farm (1 <= W <= 80, 1 <= H <= 1000) and wishes to determine the largest 'contiguous' (connected) pasture. Pastures are contiguous when any

2017-02-28 01:58:41 402

原创 Swust OJ 004 Maze Problem

Time limit(ms): 1000Memory limit(kb): 65535Submission: 661Accepted: 280Accepted搜索Given a maze, find a shortest path from start to goal.DescriptionInput cons

2017-02-28 00:54:43 473

原创 Swust OJ 0002 Prime Path

The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices. — It is a matter of s

2017-02-28 00:16:03 414

原创 OpenJudge-Noi 2000 最长公共子上升序列

总时间限制: 10000ms 内存限制: 65536kB描述给定两个整数序列,写一个程序求它们的最长上升公共子序列。当以下条件满足的时候,我们将长度为N的序列S1 , S2 , . . . , SN 称为长度为M的序列A1 , A2 , . . . , AM的上升子序列:存在 1 1 2 N j = Aij,且对于所有的1 j j+1。输入每个序列用两行表示,第

2017-02-26 11:42:32 1969

原创 OpenJudge-Noi 1808 公共子序列

总时间限制: 1000ms 内存限制: 65536kB描述我们称序列Z = 1, z2, ..., zk >是序列X = 1, x2, ..., xm >的子序列当且仅当存在 严格上升 的序列1, i2, ..., ik >,使得对j = 1, 2, ... ,k, 有xij = zj。比如Z = 是X = 的子序列。现在给出两个序列X和Y,你的任务是找到X和Y的最大公共

2017-02-25 11:38:05 630

原创 OpenJudge-Noi 1481 Maximum Sum

总时间限制: 1000ms 内存限制: 65536kB描述Given a set of n integers: A={a1, a2,..., an}, we define a function d(A) as below: t1 t2 d(A) = max{ ∑ai + ∑aj | 1 <= s1 <= t1 <

2017-02-24 23:00:06 571

原创 OpenJudge-Noi 1996 登山

总时间限制: 5000ms 内存限制: 131072kB描述五一到了,PKU-ACM队组织大家去登山观光,队员们发现山上一个有N个景点,并且决定按照顺序来浏览这些景点,即每次所浏览景点的编号都要大于前一个浏览景点的编号。同时队员们还有另一个登山习惯,就是不连续浏览海拔相同的两个景点,并且一旦开始下山,就不再向上走了。队员们希望在满足上面条件的同时,尽可能多的浏览景点,你能帮他们

2017-02-24 17:56:59 546

原创 OpenJudge-Noi 2728 摘花生

总时间限制: 1000ms 内存限制: 65536kB描述Hello Kitty 想摘点花生送给她喜欢的米老鼠。她来到一片有网格状道路的矩形花生地(如下图),从西北角进去,东南角出来。地里每个道路的交叉点上都有种着一株花生苗,上面有若干颗花生,经过一株花生苗就能摘走该它上面所有的花生。Hello Kitty只能向东或向南走,不能向西或向北走。问Hello Kitty 最多能够摘到多少颗

2017-02-24 10:34:25 475

转载 给河马刷牙(龙应台)

1. 现实的一代 安德烈: 我注意到,你很不屑于回答我这个问题:“你将来想做什么”,所以跟我胡诌一通。 是你们这个世代的人,对于未来太自信,所以不屑于像我这一代人年轻时一样,讲究勤勤恳恳,如履薄冰,还是,其实你们对于未来太没信心,太害怕,所以假装出一种嘲讽和狂妄的姿态,来闪避我的追问? 我几乎要相信,你是在假装潇洒了。今天的青年人对于未来,潇洒得起来吗?法国年轻人在街头呼喊抗议的镜

2017-02-23 22:40:24 755

原创 OpenJudge 1768 最大子矩阵(区间dp)

总时间限制: 1000ms 内存限制: 65536kB描述已知矩阵的大小定义为矩阵中所有元素的和。给定一个矩阵,你的任务是找到最大的非空(大小至少是1 * 1)子矩阵。比如,如下4 * 4的矩阵0 -2 -7 09 2 -6 2-4 1 -4 1-1 8 0 -2的最大子矩阵是9 2-4 1-1 8这个子矩阵的大小是15。

2017-02-23 22:16:04 537

空空如也

空空如也

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

TA关注的人

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