PAT刷题
文章平均质量分 67
dazhangyu97
补充信息是一件很烦的事情,因为我必须要扯一些文字来说明自己,而实际上我这个人没什么好说的。
展开
-
PAT-2019年春季考试-甲级7-3 Telefraud Detection (25分)
7-3 Telefraud Detection (25分)Telefraud(电信诈骗) remains a common and persistent problem in our society. In some cases, unsuspecting victims lose their entire life savings. To stop this crime, you are su...原创 2020-03-11 18:11:09 · 276 阅读 · 3 评论 -
PAT-2019年冬季考试-甲级7-4 Cartesian Tree (30分)
A Cartesian tree is a binary tree constructed from a sequence of distinct numbers. The tree is heap-ordered, and an inorder traversal returns the original sequence. For example, given the sequence { 8...原创 2020-02-21 22:23:11 · 268 阅读 · 0 评论 -
[PAT甲] 2019年冬季考试7-1 Good in C (20分)
这个题目有点搞人Input Specification:Each input file contains one test case. For each case, the first part gives the 26 capital English letters A-Z, each in a 7×5 matrix of C’s and .'s. Then a sentence is gi...原创 2020-02-21 22:18:54 · 241 阅读 · 0 评论 -
PAT(甲级)2019年秋季考试 7-4 Dijkstra Sequence (30分)
7-4 Dijkstra Sequence (30分)状态:ACedDijkstra’s algorithm is one of the very famous greedy algorithms. It is used for solving the single source shortest path problem which gives the shortest paths from...原创 2019-12-05 19:26:08 · 659 阅读 · 0 评论 -
PAT(甲级) 2019秋季考试 7-3 Postifix Expression (25分)
7-3 Postfix Expression (25分)状态:ACedGiven a syntax tree (binary), you are supposed to output the corresponding postfix expression, with parentheses reflecting the precedences of the operators.Input ...原创 2019-12-05 19:19:27 · 197 阅读 · 0 评论 -
PAT(甲级)2019年秋季考试 7-2 Merging Linked Lists (25分)
7-2 Merging Linked Lists (25分)状态:ACedGiven two singly linked lists L1=a1→a2 →⋯→an−1→an and L2=b1→b2→⋯→bm−1→bm . If n≥2m, you are supposed to reverse and merge the shorter one into the longer ...原创 2019-12-05 19:00:18 · 830 阅读 · 0 评论 -
PAT(甲级)2019年秋季考试 7-1 Forever (20分)
7-1 Forever (20分)“Forever number” is a positive integer A with K digits, satisfying the following constrains:the sum of all the digits of A is m;the sum of all the digits of A+1 is n; andthe great...原创 2019-12-05 18:52:08 · 390 阅读 · 0 评论 -
06-图3 六度空间(30 分)
06-图3 六度空间(30 分)“六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图1所示。\ “六度空间”理论虽然得到广泛的认同,并且正在得到越来越多的应用。但是数十年来,试图验证这个理论始终是许多社会学家努力追求的目标原创 2017-10-28 21:03:13 · 575 阅读 · 0 评论 -
06-图2 Saving James Bond - Easy Version(25 分)
06-图2 Saving James Bond - Easy Version(25 分)This time let us consider the situation in the movie “Live and Let Die” in which James Bond, the world’s most famous spy, was captured by a group of drug dea原创 2017-10-28 20:58:00 · 312 阅读 · 0 评论 -
05-树9 Huffman Codes(30 分)
05-树9 Huffman Codes(30 分)In 1953, David A. Huffman published his paper “A Method for the Construction of Minimum-Redundancy Codes”, and hence printed his name in the history of computer science. As a p原创 2017-10-28 20:52:41 · 730 阅读 · 0 评论 -
05-树8 File Transfer(25 分)
05-树8 File Transfer(25 分)We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible原创 2017-10-28 20:33:31 · 318 阅读 · 0 评论 -
04-树6 Complete Binary Search Tree(30 分)
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原创 2017-10-20 08:43:50 · 291 阅读 · 0 评论 -
04-树5 Root of AVL Tree(25 分)
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 dif原创 2017-10-20 00:25:15 · 433 阅读 · 0 评论 -
[PAT] 1015. 德才论 (25)
宋代史学家司马光在《资治通鉴》中有一段著名的“德才论”:“是故才德全尽谓之圣人,才德兼亡谓之愚人,德胜才谓之君子,才胜德谓之小人。凡取人之术,苟不得圣人,君子而与之,与其得小人,不若得愚人。”现给出一批考生的德才分数,请根据司马光的理论给出录取排名。输入格式:输入第1行给出3个正整数,分别为:N(<=105),即考生总数;L(>=60),为录取最低分数线,即德分和才分均不低于L的考生才有资格被考虑录原创 2017-10-02 14:55:11 · 166 阅读 · 0 评论 -
[PTA] 线性结构2 一元多项式的乘法与加法运算(20 分)
线性结构2 一元多项式的乘法与加法运算(20 分)设计函数分别求两个一元多项式的乘积与和。输入格式: 输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式: 输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应输出0 0。原创 2017-09-27 16:01:08 · 255 阅读 · 0 评论 -
[PTA MOOC] Maximum Subsequence Sum(25 分)(也是浙大研究生机试的题)
01-复杂度2 Maximum Subsequence Sum(25 分)原创 2017-09-01 23:07:47 · 555 阅读 · 0 评论 -
[PAT乙] 1003 我要通过!
1003. 我要通过!(20)“答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。得到“答案正确”的条件是:字符串中必须仅有P, A, T这三种字符,不可以包含其它字符;任意形如 xPATx 的字符串都可以获得“答案正确”,其中 x 或者是空字符串,或者是仅由字母 A 组成的字符串原创 2017-09-28 16:23:04 · 216 阅读 · 0 评论 -
[PAT乙] 1005. 继续(3n+1)猜想 (25)
1005. 继续(3n+1)猜想 (25)卡拉兹(Callatz)猜想已经在1001中给出了描述。在这个题目里,情况稍微有些复杂。当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数。例如对n=3进行验证的时候,我们需要计算3、5、8、4、2、1,则当我们对n=5、8、4、2进行验证的时候,就可以直接判定卡拉兹猜想的真伪,而不需要重复计算,因为这4个数已经在验证3的时候遇原创 2017-09-28 21:41:42 · 194 阅读 · 0 评论 -
[PAT乙] 1007. 素数对猜想 (20)
1007. 素数对猜想 (20)让我们定义 dn 为:dn = pn+1 - pn,其中 pi 是第i个素数。显然有 d1=1 且对于n>1有 dn 是偶数。“素数对猜想”认为“存在无穷多对相邻且差为2的素数”。现给定任意正整数N (< 105),请计算不超过N的满足猜想的素数对的个数。输入格式:每个测试输入包含1个测试用例,给出正整数N。输出格式:每个测试用例的输出占一行,不超过N的满足猜想的素数原创 2017-09-29 00:55:51 · 182 阅读 · 0 评论 -
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 stack原创 2017-10-17 17:17:29 · 286 阅读 · 0 评论 -
[PAT乙] 1019. 数字黑洞 (20)
1019. 数字黑洞 (20)给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第1个数字减第2个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的6174,这个神奇的数字也叫Kaprekar常数。例如,我们从6767开始,将得到7766 - 6677 = 1089 9810 - 0189 = 9621 9621 - 12原创 2017-10-08 23:20:54 · 261 阅读 · 0 评论 -
[PAT甲] 1074.Reversing Linked List
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→4; if K=4,原创 2017-09-30 17:05:47 · 185 阅读 · 0 评论 -
[PAT甲] 1051.Pop Sequence
Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the原创 2017-09-30 17:23:42 · 460 阅读 · 1 评论 -
[PAT乙] 1014. 福尔摩斯的约会 (20)
大侦探福尔摩斯接到一张奇怪的字条:“我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm”。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间“星期四 14:04”,因为前面两字符串中第1对相同的大写英文字母(大小写有区分)是第4个字母’D’,代表星期四;第2对相同的字符是’E’,那是第5个英文字母,代表一天里的第14个钟头(原创 2017-10-02 14:26:38 · 259 阅读 · 0 评论 -
[PTA] 线性结构1 两个有序链表序列的合并(15 分)
线性结构1 两个有序链表序列的合并(15 分)本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列。函数接口定义: List Merge( List L1, List L2 );其中List结构定义如下:typedef struct Node *PtrToNode;struct Node { ElementType Data; /* 存储结点数据 */ P原创 2017-09-27 00:24:33 · 590 阅读 · 0 评论