![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT甲级
彼年旧影
Just Coding
展开
-
A1035 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 distinguish1(one) froml(L...原创 2020-03-19 13:49:28 · 129 阅读 · 0 评论 -
A1034 Head of a Gang (30分)
One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call betweenAandB, we say thatAandBis related. The weight of a relation is defined to be t...原创 2020-03-18 22:35:13 · 206 阅读 · 0 评论 -
A1033 To Fill or Not to Fill (25分)
With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different ga...原创 2020-03-18 22:33:59 · 106 阅读 · 0 评论 -
A1032 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,...原创 2020-03-18 22:32:33 · 117 阅读 · 0 评论 -
A1031 Hello World for U (20分)
Given any string ofN(≥5) characters, you are asked to form the characters into the shape ofU. For example,helloworldcan be printed as:h de ll rlowoThat is, the characters must be prin...原创 2020-03-18 22:31:11 · 94 阅读 · 0 评论 -
A1030 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...原创 2020-03-18 22:29:59 · 122 阅读 · 0 评论 -
A1028 List Sorting (25分)
Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contains two...原创 2020-03-18 22:28:33 · 99 阅读 · 0 评论 -
A1027 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 forRed, the middle 2 dig...原创 2020-03-18 22:27:02 · 83 阅读 · 0 评论 -
A1025 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...原创 2020-03-18 09:50:08 · 93 阅读 · 0 评论 -
A1022 Digital Library (30分)
A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit numbe...原创 2020-03-17 22:41:57 · 124 阅读 · 0 评论 -
A1021 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 ...原创 2020-03-17 22:38:25 · 107 阅读 · 0 评论 -
A1020 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...原创 2020-03-17 22:37:18 · 83 阅读 · 0 评论 -
A1019 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...原创 2020-03-17 22:36:05 · 123 阅读 · 0 评论 -
A1018 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 ...原创 2020-03-17 22:34:18 · 170 阅读 · 0 评论 -
A1015 Reversible Primes (20分)
Areversible primein any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a pr...原创 2020-03-17 22:32:43 · 75 阅读 · 0 评论 -
A1013 Battle Over Cities (25分)
It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we nee...原创 2020-03-17 22:31:19 · 104 阅读 · 0 评论 -
A1012 The Best Rank (25分)
To evaluate the performance of our first year CS majored students, we consider their grades of three courses only:C- C Programming Language,M- Mathematics (Calculus or Linear Algrbra), andE- Eng...原创 2020-03-17 22:30:01 · 85 阅读 · 0 评论 -
A1011 World Cup Betting (20分)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World Cup trophy in South Africa. Si...原创 2020-03-17 15:45:39 · 120 阅读 · 0 评论 -
A1010 Radix (25分)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer isyes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive inte...原创 2020-03-16 23:43:54 · 109 阅读 · 0 评论 -
A1009 Product of Polynomials (25分)
This time, you are supposed to findA×BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the informa...原创 2020-03-16 23:42:46 · 96 阅读 · 0 评论 -
A1008 Elevator (20分)
The highest building in our city has only one elevator. A request list is made up withNpositive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 sec...原创 2020-03-16 23:41:26 · 194 阅读 · 0 评论 -
A1007 Maximum Subsequence Sum (25分)
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 subsequen...原创 2020-03-16 23:38:54 · 87 阅读 · 0 评论 -
A1006 Sign In and Sign Out (25分)
At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the records of signing in's and out's, you...原创 2020-03-16 23:37:54 · 94 阅读 · 0 评论 -
A1005 Spell It Right (20分)
Given a non-negative integerN, your task is to compute the sum of all the digits ofN, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Eac...原创 2020-03-16 23:36:39 · 96 阅读 · 0 评论 -
A1004 Counting Leaves (30分)
A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.Input Specification:Each input file contains one test case. Each case starts...原创 2020-03-16 23:35:25 · 152 阅读 · 0 评论 -
A1003 Emergency (25 分)
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l...原创 2019-09-03 18:54:48 · 164 阅读 · 0 评论 -
A1002 A+B for Polynomials (25分)
This time, you are supposed to findA+BwhereAandBare two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the informa...原创 2020-03-16 23:31:57 · 90 阅读 · 0 评论 -
A1001 A+B Format (20分)
Calculatea+band output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Input Specification:Each input ...原创 2020-03-16 23:30:42 · 107 阅读 · 0 评论 -
1119. Pre- and Post-order Traversals (30)-PAT甲级真题(前序后序转中序)
题目描述Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences, or preorder and in...原创 2019-08-29 20:20:13 · 233 阅读 · 2 评论 -
1129 Recommendation System(25 分)
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...原创 2019-08-31 20:35:13 · 147 阅读 · 0 评论 -
A1158-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 supposed to write a program to d...原创 2019-09-01 14:30:41 · 344 阅读 · 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-09-02 18:46:01 · 181 阅读 · 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-09-02 20:56:06 · 114 阅读 · 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 (i...原创 2019-09-03 11:19:37 · 118 阅读 · 0 评论 -
1147 Heaps (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 (i...原创 2019-09-03 11:54:00 · 91 阅读 · 0 评论 -
1159.Structure of a Binary Tree (30 分)(二叉树,map,中序后序建树-顺便求高,sscanf的使用)
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, a binary tree can be uniquely determined.Now given a sequence of state...原创 2019-09-01 14:13:19 · 351 阅读 · 0 评论