08 2018 档案
【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 阅读全文
posted @ 2018-08-26 19:21 Pink.Pig 阅读(253) 评论(0) 推荐(0)
【PAT】1053 Path of Equal Weight(30 分)
摘要:Given a non-empty tree with root R, and with weight W​i​​ assigned to each tree node T​i​​. The weight of a path from R to L is defined to be the sum 阅读全文
posted @ 2018-08-26 16:36 Pink.Pig 阅读(232) 评论(0) 推荐(0)
【PAT】1020 Tree Traversals (25)(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 ou 阅读全文
posted @ 2018-08-24 21:18 Pink.Pig 阅读(153) 评论(0) 推荐(0)
【PAT】1091 Acute Stroke(30 分)
摘要:One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions 阅读全文
posted @ 2018-08-24 17:34 Pink.Pig 阅读(973) 评论(0) 推荐(0)
【PAT】1103 Integer Factorization(30 分)
摘要:The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program t 阅读全文
posted @ 2018-08-24 15:40 Pink.Pig 阅读(203) 评论(0) 推荐(0)
【PAT】1051 Pop Sequence (25)(25 分)
摘要: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 s 阅读全文
posted @ 2018-08-23 18:39 Pink.Pig 阅读(447) 评论(0) 推荐(0)
【PAT】1052 Linked List Sorting (25)(25 分)
摘要:A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key 阅读全文
posted @ 2018-08-23 17:45 Pink.Pig 阅读(140) 评论(0) 推荐(0)
【PAT】1060 Are They Equal (25)(25 分)
摘要:If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123*10^5^ wit 阅读全文
posted @ 2018-08-22 17:47 Pink.Pig 阅读(185) 评论(0) 推荐(0)
【PAT】1032 Sharing (25)(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 s 阅读全文
posted @ 2018-08-22 17:38 Pink.Pig 阅读(225) 评论(0) 推荐(0)
【PAT】1019 数字黑洞 (20)(20 分)
摘要:给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第1个数字减第2个数字,将得到一个新的数字。一直重复这样做,我们很快会停在有“数字黑洞”之称的6174,这个神奇的数字也叫Kaprekar常数。 例如,我们从6767开始,将得到 7766 - 6677 阅读全文
posted @ 2018-08-19 21:17 Pink.Pig 阅读(253) 评论(0) 推荐(0)
【PAT】1018 锤子剪刀布 (20)(20 分)
摘要:1018 锤子剪刀布 (20)(20 分) 大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示: 现给出两人的交锋记录,请统计双方的胜、平、负次数,并且给出双方分别出什么手势的胜算最大。 输入格式: 输入第1行给出正整数N(<=10^5^),即双方交锋的次数。随后N行,每行给出一 阅读全文
posted @ 2018-08-19 19:58 Pink.Pig 阅读(2346) 评论(0) 推荐(0)
【PAT】1017 A除以B(20 分)
摘要:本题要求计算 A/B,其中 A 是不超过 1000 位的正整数,B 是 1 位正整数。你需要输出商数 Q 和余数 R,使得 A=B×Q+R 成立。 输入格式: 输入在一行中依次给出 A 和 B,中间以 1 空格分隔。 输出格式: 在一行中依次输出 Q 和 R,中间以 1 空格分隔。 输入样例: 12 阅读全文
posted @ 2018-08-19 17:22 Pink.Pig 阅读(2465) 评论(1) 推荐(1)
【PAT】1016 部分A+B(15 分)
摘要:正整数 A 的“D​A​​(为 1 位整数)部分”定义为由 A 中所有 D​A​​ 组成的新整数 P​A​​。例如:给定 A=3862767,D​A​​=6,则 A 的“6 部分”P​A​​ 是 66,因为 A 中有 2 个 6。 现给定 A、D​A​​、B、D​B​​,请编写程序计算 P​A​​+ 阅读全文
posted @ 2018-08-19 15:21 Pink.Pig 阅读(1283) 评论(0) 推荐(0)
【PAT】1015 德才论 (25)(25 分)
摘要:1015 德才论 (25)(25 分) 宋代史学家司马光在《资治通鉴》中有一段著名的“德才论”:“是故才德全尽谓之圣人,才德兼亡谓之愚人,德胜才谓之君子,才胜德谓之小人。凡取人之术,苟不得圣人,君子而与之,与其得小人,不若得愚人。” 现给出一批考生的德才分数,请根据司马光的理论给出录取排名。 输入格 阅读全文
posted @ 2018-08-19 14:53 Pink.Pig 阅读(1333) 评论(0) 推荐(0)