PAT集训
思念在延续
这个作者很懒,什么都没留下…
展开
-
1140 Look-and-say Sequence (20 分)
Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth n...原创 2019-01-17 10:53:02 · 123 阅读 · 0 评论 -
1150 Travelling Salesman Problem (25 分)
The "travelling salesman problem" asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and retu...原创 2019-01-15 11:52:15 · 300 阅读 · 0 评论 -
1148 Werewolf - Simple Version (20 分)
Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: "Player #2 is a werewolf."; player #2 said...原创 2019-01-15 16:17:17 · 505 阅读 · 1 评论 -
1149 Dangerous Goods Packaging (25 分)
When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂)...原创 2019-01-15 19:28:27 · 309 阅读 · 0 评论 -
1144 The Missing Number (20 分)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line giv...原创 2019-01-16 09:47:21 · 237 阅读 · 0 评论 -
1145 Hashing - Average Search Time (25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...原创 2019-01-16 11:04:06 · 255 阅读 · 0 评论 -
1146 Topological Order (25 分)
This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test...原创 2019-01-16 15:46:37 · 105 阅读 · 0 评论 -
1147 Heaps (30 分)
In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...原创 2019-01-16 17:00:04 · 258 阅读 · 0 评论 -
1134 Vertex Cover (25 分)
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if e...原创 2019-02-14 17:31:01 · 176 阅读 · 0 评论 -
1139 First Contact (30 分)
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly i...原创 2019-02-07 20:54:05 · 256 阅读 · 0 评论 -
1138 Postorder Traversal (25 分)
Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...原创 2019-02-09 19:28:42 · 102 阅读 · 0 评论 -
1137 Final Grading (25 分)
For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from...原创 2019-02-11 20:35:27 · 146 阅读 · 0 评论 -
1133 Splitting A Linked List (25 分)
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea...原创 2019-02-17 20:06:28 · 144 阅读 · 0 评论 -
1132 Cut Integer (20 分)
Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting...原创 2019-02-18 09:51:22 · 258 阅读 · 0 评论 -
1151 LCA in a Binary Tree (30 分)
The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.In...原创 2019-01-14 17:07:22 · 163 阅读 · 0 评论 -
1155 Heap Paths (30 分)
In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...原创 2019-01-13 20:09:59 · 250 阅读 · 0 评论 -
1141 PAT Ranking of Institutions (25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.Input Specification:Each input file conta...原创 2019-01-17 14:53:46 · 200 阅读 · 0 评论 -
1142 Maximal Clique (25 分)
A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adj...原创 2019-01-17 16:26:13 · 152 阅读 · 0 评论 -
1143 Lowest Common Ancestor (30 分)
The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree which has ...原创 2019-01-17 17:34:50 · 490 阅读 · 0 评论 -
1086 就不告诉你 (15 分)
作者: CHEN, Yue单位: 浙江大学时间限制: 400 ms内存限制: 64 MB代码长度限制: 16 KB做作业的时候,邻座的小盆友问你:“五乘以七等于多少?”你应该不失礼貌地围笑着告诉他:“五十三。”本题就要求你,对任何一对给定的正整数,倒着输出它们的乘积。输入格式:输入在第一行给出两个不超过 1000 的正整数 A 和 B,其间以空格分隔。输出格式:...原创 2019-01-12 15:38:29 · 2368 阅读 · 2 评论 -
1087 有多少不同的值 (20 分)
作者: CHEN, Yue单位: 浙江大学时间限制: 150 ms内存限制: 64 MB代码长度限制: 16 KB 当自然数 n 依次取 1、2、3、……、N 时,算式 ⌊n/2⌋+⌊n/3⌋+⌊n/5⌋ 有多少个不同的值?(注:⌊x⌋ 为取整函数,表示不超过 x 的最大自然数,即 x 的整数部分。)输入格式:输入给出一个正整数 N(2≤N≤104)。输出...原创 2019-01-12 16:15:41 · 659 阅读 · 0 评论 -
1088 三人行 (20 分)
作者: CHEN, Yue单位: 浙江大学时间限制: 400 ms内存限制: 64 MB代码长度限制: 16 KB 子曰:“三人行,必有我师焉。择其善者而从之,其不善者而改之。”本题给定甲、乙、丙三个人的能力值关系为:甲的能力值确定是 2 位正整数;把甲的能力值的 2 个数字调换位置就是乙的能力值;甲乙两人能力差是丙的能力值的 X 倍;乙的能力值是丙的 Y 倍。请你指出...原创 2019-01-12 17:19:15 · 106 阅读 · 0 评论 -
1091 N-自守数 (15 分)
如果某个数 K 的平方乘以 N 以后,结果的末尾几位数等于 K,那么就称这个数为“N-自守数”。例如 3×922=25392,而 25392 的末尾两位正好是 92,所以 92 是一个 3-自守数。本题就请你编写程序判断一个给定的数字是否关于某个 N 是 N-自守数。输入格式:输入在第一行中给出正整数 M(≤20),随后一行给出 M 个待检测的、不超过 1000 的正整数。输...原创 2019-01-12 18:48:37 · 389 阅读 · 0 评论 -
1092 最好吃的月饼 (20 分)
月饼是久负盛名的中国传统糕点之一,自唐朝以来,已经发展出几百品种。若想评比出一种“最好吃”的月饼,那势必在吃货界引发一场腥风血雨…… 在这里我们用数字说话,给出全国各地各种月饼的销量,要求你从中找出销量冠军,认定为最好吃的月饼。输入格式:输入首先给出两个正整数 N(≤1000)和 M(≤100),分别为月饼的种类数(于是默认月饼种类从 1 到 N 编号)和参与统计的城市数量。接...原创 2019-01-12 19:33:14 · 522 阅读 · 0 评论 -
1093 字符串A+B (20 分)
给定两个字符串 A 和 B,本题要求你输出 A+B,即两个字符串的并集。要求先输出 A,再输出 B,但重复的字符必须被剔除。输入格式:输入在两行中分别给出 A 和 B,均为长度不超过 106的、由可见 ASCII 字符 (即码值为32~126)和空格组成的、由回车标识结束的非空字符串。输出格式:在一行中输出题面要求的 A 和 B 的和。输入样例:This is a ...原创 2019-01-12 20:11:01 · 508 阅读 · 0 评论 -
1094 谷歌的招聘 (20 分)1152 Google Recruitment (20 分)
2004 年 7 月,谷歌在硅谷的 101 号公路边竖立了一块巨大的广告牌(如下图)用于招聘。内容超级简单,就是一个以 .com 结尾的网址,而前面的网址是一个 10 位素数,这个素数是自然常数 e 中最早出现的 10 位连续数字。能找出这个素数的人,就可以通过访问谷歌的这个网站进入招聘流程的下一步。自然常数 e 是一个著名的超越数,前面若干位写出来是这样的:e = 2.718281828...原创 2019-01-12 20:24:10 · 226 阅读 · 0 评论 -
1095 解码PAT准考证 (25 分)1153 Decode Registration Card of PAT (25 分)
PAT 准考证号由 4 部分组成:第 1 位是级别,即 T 代表顶级;A 代表甲级;B 代表乙级; 第 2~4 位是考场编号,范围从 101 到 999; 第 5~10 位是考试日期,格式为年、月、日顺次各占 2 位; 最后 11~13 位是考生编号,范围从 000 到 999。现给定一系列考生的准考证号和他们的成绩,请你按照要求输出各种统计信息。输入格式:输入首先在一行中给出...原创 2019-01-13 11:08:02 · 297 阅读 · 0 评论 -
1154 Vertex Coloring (25 分)
A proper vertex coloring is a labeling of the graph's vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at most kcolors is called a (proper) k-...原创 2019-01-13 16:11:59 · 135 阅读 · 0 评论 -
1136 A Delayed Palindrome (20 分)
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 with 0≤ai<10 for all i and ak>0. Then N is palindromic if and only if ai=ak−i for...原创 2019-02-13 14:19:52 · 129 阅读 · 0 评论