
PAT (Advanced Level)
「已注销」
这个作者很懒,什么都没留下…
展开
-
PAT(甲级)2019年春季考试
7-1Sexy Primes(20分)Sexy primes are pairs of primes of the form (p,p+6), so-named since "sex" is the Latin word for "six". (Quoted fromhttp://mathworld.wolfram.com/SexyPrimes.html)Now given an integer, you are supposed to tell if it is a sexy prime....原创 2020-07-23 18:15:52 · 794 阅读 · 0 评论 -
7-2 Block Reversing (25分) 【PAT 甲级19年冬考】
Given a singly linked listL. Let us consider everyKnodes as ablock(if there are less thanKnodes at the end of the list, the rest of the nodes are still considered as a block). Your job is to reverse all the blocks inL. For example, givenLas 1→2→3...原创 2020-07-22 10:53:48 · 519 阅读 · 6 评论 -
7-3 Summit (25分) [PAT甲级 19年冬考]
Asummit(峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so that everyone is a direct friend of everyone.Now given a set of tentati..原创 2020-07-22 10:34:23 · 173 阅读 · 0 评论 -
1117 Eddington Number (25分)
British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an "Eddington number",E-- that is, the maximum integerEsuch that it is forEdays that one rides more thanEmiles. Eddington's ownE...原创 2020-07-11 00:00:47 · 137 阅读 · 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 greater than K. The order of the elements inside each class原创 2020-07-09 23:50:02 · 147 阅读 · 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: "Player #3 is a human."; player #3 said: "Player #4 i原创 2020-07-09 01:07:00 · 175 阅读 · 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 to see that Z can be devided by the product of A and...原创 2020-07-05 01:02:46 · 117 阅读 · 0 评论 -
1129 Recommendation System (25分)
Recommendation system predicts the preference that a user would give to an item. Now you are asked to program a very simple recommendation system that rates the user's preference by the number of times that an item has been accessed by this user.Input Sp原创 2020-07-05 00:38:50 · 168 阅读 · 0 评论 -
1121 Damn Single (25分)
"Damn Single (单身狗)" is the Chinese nickname for someone who is being single. You are supposed to find those who are alone in a big party, so they can be taken care of.Input Specification:Each input file contains one test case. For each case, the first原创 2020-07-03 00:46:04 · 109 阅读 · 0 评论 -
1109 Group Photo (25分)
Formation is very important when taking a group photo. Given the rules of formingKrows withNpeople as the following: The number of people in each row must beN/K(round down to the nearest integer), with all the extra people (if any) standing in the...原创 2020-07-02 00:52:21 · 175 阅读 · 0 评论 -
1105 Spiral Matrix (25分)
This time your job is to fill a sequence ofNpositive integers into aspiral matrixin non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then move in a clockwise spiral. The matrix hasmrows andncolumns...原创 2020-07-01 01:27:49 · 131 阅读 · 0 评论 -
1014 Waiting in Line (30分)
Suppose a bank hasNwindows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wait in line are:The space inside the yellow line in front of each window is enoug..原创 2020-06-28 01:10:20 · 201 阅读 · 1 评论 -
1152 Google Recruitment (20分)
In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown in the picture below) for recruitment. The content is super-simple, a URL consisting of the first 10-digit prime found in consecutive digits of the natural constant原创 2020-06-27 01:02:31 · 111 阅读 · 0 评论 -
1116 Come on Lets C (20分)
"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny as the following:0、 The Champion will receive a "Mystery原创 2020-06-26 01:27:46 · 219 阅读 · 0 评论 -
1112 Stucked Keyboard (20分)
On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen forktimes.Now given a resulting string on screen, you are supposed to list all th...原创 2020-06-25 01:36:03 · 180 阅读 · 0 评论 -
1072 Gas Station (30分)
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range.Now given the map of t...原创 2020-06-24 00:24:56 · 171 阅读 · 0 评论 -
1018 Public Bike Management (30分)
There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the city.The Public Bike Management Center (PBMC) keeps mo原创 2020-06-21 01:34:43 · 106 阅读 · 0 评论 -
1136 A Delayed Palindrome (20分)
Consider a positive integerNwritten in standard notation withk+1digitsaiasak⋯a1a0with0≤ai<10for alliandak>0. ThenNispalindromicif and only ifai=ak−ifor alli. Zero is written 0 and is also palindromic by def...原创 2020-06-18 01:14:20 · 125 阅读 · 0 评论 -
1153 Decode Registration Card of PAT (25分)
A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBfor basic; the 2nd - 4th digits are the test site number, ranged from 101 to 999; the 5th - 10th digits giv...原创 2020-06-17 01:50:42 · 163 阅读 · 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 contains one test case. For each case, the first line gives a原创 2020-06-15 00:30:58 · 132 阅读 · 0 评论 -
1124 Raffle for Weibo Followers (20分)
John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are supposed to help him generate t原创 2020-06-14 00:55:29 · 145 阅读 · 0 评论 -
1108 Finding Average (20分)
The basic task is simple: givenNreal numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. Alegalinput is a real number in [−1000,1000] and is accurate up to no more th...原创 2020-06-13 01:00:39 · 135 阅读 · 0 评论 -
1130 Infix Expression (25分)
Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Each input file contains one test case. For each case, the first line gives a原创 2020-06-04 01:19:20 · 103 阅读 · 0 评论 -
1155 Heap Paths (30分)
In computer science, aheapis 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 (in a max heap) or less than or equal to (in a min heap) t..原创 2020-06-03 00:26:55 · 107 阅读 · 0 评论 -
1114 Family Property (25分)
This time, you are supposed to help us collect the data for family-owned property. Given each person's family members, and the estate(房产)info under his/her own name, we need to know the size of each family, and the average area and number of sets of their原创 2020-05-29 22:31:58 · 137 阅读 · 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 the online programming assignments, and then receive a原创 2020-05-25 02:26:48 · 108 阅读 · 0 评论 -
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 (氧化剂) must not be packed with flammable liquid (易燃液体), or it原创 2020-05-24 01:35:13 · 138 阅读 · 0 评论 -
1120 Friend Numbers (20分)
Two integers are called "friend numbers" if they share the same sum of their digits, and the sum is their "friend ID". For example, 123 and 51 are friend numbers since 1+2+3 = 5+1 = 6, and 6 is their friend ID. Given some numbers, you are supposed to co...原创 2020-05-24 00:29:02 · 112 阅读 · 0 评论 -
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 together to form her favorite color stripe.It is said原创 2020-05-22 00:15:36 · 136 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25分) [DP]
Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of its elements. For exa...原创 2020-05-21 00:54:24 · 161 阅读 · 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 in the first place. Instead, he might ask another boy ...原创 2020-05-16 00:18:09 · 274 阅读 · 0 评论 -
1131 Subway Map (30分)
In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are supposed to help people with your computer skills! Given the starting position of you...原创 2020-05-15 00:43:45 · 192 阅读 · 0 评论 -
1019 General Palindromic Number (20分)
A number that will be the same when it is written forwards or backwards is known as aPalindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Although palindromic numbers are most often considere.原创 2020-05-11 23:41:05 · 116 阅读 · 0 评论 -
1142 Maximal Clique (25分)
Acliqueis a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. Amaximal cliqueis a clique that cannot be extended by including one more adjacent vertex. (Quoted fromhttps://en.wikipedia.org/wiki...原创 2020-05-11 00:45:58 · 162 阅读 · 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 each of the options.Input Specification:Each i...原创 2020-05-10 00:55:13 · 117 阅读 · 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 returns to the origin city?" It is an NP-hard problem in ...原创 2020-05-09 00:45:55 · 106 阅读 · 0 评论 -
1154 Vertex Coloring (25分)
Aproper vertex coloringis 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 mostkcolors is called a (proper...原创 2020-05-08 00:53:31 · 85 阅读 · 0 评论 -
1134 Vertex Cover (25分)[模拟]
Avertex coverof 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 i...原创 2020-05-08 00:16:25 · 118 阅读 · 0 评论 -
1126 Eulerian Path (25分)
In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They were firs...原创 2020-05-06 00:48:22 · 160 阅读 · 0 评论 -
1111 Online Map (30分) [Dijkstra]
Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other is the fastest. It is g...原创 2020-05-04 23:57:23 · 141 阅读 · 0 评论