PAT甲级题解
文章平均质量分 69
ssf_cxdm
wei hai da xue
展开
-
1141 PAT Ranking of Institutions
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 contain...原创 2018-09-25 22:05:02 · 178 阅读 · 0 评论 -
1146 Topological Order
1146 Topological OrderThis 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 ...原创 2018-09-26 20:39:32 · 100 阅读 · 0 评论 -
1073 Scientific Notation
1073 Scientific NotationScientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [±][1-9].[0-9]+E[±][0-9]+ wh...原创 2018-10-03 20:46:32 · 244 阅读 · 0 评论 -
1077 Kuchiguse
1077 KuchiguseThe Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker’s personality. Such a prefer...原创 2018-10-03 20:57:59 · 188 阅读 · 0 评论 -
1081 Rational Sum
1081 Rational SumGiven N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts wit...原创 2018-10-03 21:02:13 · 167 阅读 · 0 评论 -
1084 Broken Keyboard
1084 Broken KeyboardOn a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that...原创 2018-10-03 21:10:36 · 125 阅读 · 0 评论 -
1088 Rational Arithmetic
1088 Rational ArithmeticFor two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each input f...原创 2018-10-03 21:12:14 · 104 阅读 · 0 评论 -
1133 Splitting A Linked List
1133 Splitting A Linked ListGiven 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]...原创 2018-09-21 19:57:31 · 87 阅读 · 0 评论 -
1134 Vertex Cover
1134 Vertex CoverA 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 sup...原创 2018-09-21 20:03:06 · 344 阅读 · 0 评论 -
1145 Hashing - Average Search Time
1145 Hashing - Average Search TimeThe 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 t...原创 2018-09-26 20:33:47 · 220 阅读 · 0 评论 -
1026 Table Tennis
1026 Table TennisA table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be a...原创 2018-10-11 14:47:53 · 341 阅读 · 0 评论 -
1030 Travel Plan
1030 Travel PlanA 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 th...原创 2018-10-11 14:44:59 · 187 阅读 · 0 评论 -
1142 Maximal Clique
1142 Maximal CliqueA 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 in...原创 2018-09-25 22:13:26 · 105 阅读 · 0 评论 -
1129 Recommendation System
1129 Recommendation SystemRecommendation 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 prefe...转载 2018-09-20 20:46:23 · 245 阅读 · 0 评论 -
1130 Infix Expression
1130 Infix ExpressionGiven a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Ea...转载 2018-09-20 20:48:08 · 102 阅读 · 0 评论 -
1054 The Dominant Color
1054 The Dominant ColorBehind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportio...原创 2018-10-02 14:10:18 · 125 阅读 · 0 评论 -
1058 A+B in Hogwarts
1058 A+B in HogwartsIf you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twen...原创 2018-10-02 14:14:18 · 251 阅读 · 0 评论 -
1061 Dating
1061 DatingSherlock Holmes received a note with some strange strings: Let’s date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minute to figure out that those str...原创 2018-10-02 14:21:40 · 134 阅读 · 0 评论 -
1065 A+B and C (64bit)
1065 A+B and C (64bit)Given three integers A, B and C in [−263 ,263 ], you are supposed to tell whether A+B>C.Input Specification:The first line of the input gives the positive number ...原创 2018-10-02 14:39:26 · 123 阅读 · 0 评论 -
1069 The Black Hole of Numbers
1069 The Black Hole of NumbersFor any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new ...原创 2018-10-02 14:44:16 · 310 阅读 · 0 评论 -
1092 To Buy or Not to Buy
1092 To Buy or Not to BuyEva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner ...原创 2018-10-05 10:02:21 · 216 阅读 · 0 评论 -
1096 Consecutive Factors
1096 Consecutive Factors1096 Consecutive Factors (20 分)Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where ...原创 2018-10-05 10:57:04 · 174 阅读 · 0 评论 -
1100 Mars Numbers
1100 Mars NumbersPeople on Mars count their numbers with base 13:Zero on Earth is called “tret” on Mars.The numbers 1 to 12 on Earch is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov...原创 2018-10-05 11:03:30 · 271 阅读 · 0 评论 -
1140 Look-and-say Sequence
1140 Look-and-say Sequence题目链接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 o...原创 2018-10-06 15:20:49 · 193 阅读 · 0 评论 -
1144 The Missing Number
1144 The Missing NumberGiven 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 ca...原创 2018-10-06 15:27:56 · 159 阅读 · 0 评论 -
1148 Werewolf - Simple Version
1148 Werewolf - Simple Version题目链接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 ...原创 2018-10-06 16:11:59 · 217 阅读 · 0 评论 -
1015 Reversible Primes
1015 Reversible PrimesA reversible prime in 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 ...原创 2018-09-28 22:39:17 · 214 阅读 · 0 评论 -
1022 Digital Library
1022 Digital LibraryA 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 un...原创 2018-10-09 19:32:09 · 252 阅读 · 0 评论 -
1018 Public Bike Management
1018 Public Bike ManagementThere 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 t...原创 2018-10-09 19:41:09 · 134 阅读 · 0 评论 -
1053 Path of Equal Weight
1053 Path of Equal Weight题目链接Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti . The weight of a path from R to L is defined to be the sum of the weights ...原创 2018-10-16 20:51:14 · 144 阅读 · 0 评论 -
1131 Subway Map
Subway MapIn 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 peop...原创 2018-11-20 20:04:18 · 311 阅读 · 0 评论 -
1136 A Delayed Palindrome
1136 A Delayed Palindrome题目链接Consider a positive integer N written in standard notation with k+1 digits ai as ak ⋯a1 a0 with 0≤ai <10 for all i and ak >0. Then ...原创 2018-10-06 15:16:21 · 155 阅读 · 0 评论 -
1132 Cut Integer
1132 Cut IntegerCutting 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. ...原创 2018-10-06 15:12:54 · 168 阅读 · 0 评论 -
1150 Travelling Salesman Problem
1150 Travelling Salesman ProblemThe “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 rou...原创 2018-09-27 20:36:48 · 195 阅读 · 0 评论 -
1104 Sum of Number Segments
1104 Sum of Number SegmentsGiven a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0....原创 2018-10-05 11:12:43 · 198 阅读 · 0 评论 -
1108 Finding Average
1108 Finding AverageThe basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. A ...原创 2018-10-05 11:18:48 · 121 阅读 · 0 评论 -
1120 Friend Numbers
1120 Friend NumbersTwo 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 ...原创 2018-10-05 11:58:32 · 94 阅读 · 0 评论 -
1116 Come on! Let's C
1116 Come on! Let’s C“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 aw...原创 2018-10-05 12:14:54 · 227 阅读 · 0 评论 -
1124 Raffle for Weibo Followers
1124 Raffle for Weibo FollowersJohn 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 w...原创 2018-10-05 12:28:03 · 180 阅读 · 0 评论 -
1128 N Queens Puzzle
1128 N Queens PuzzleThe “eight queens puzzle” is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens...原创 2018-10-05 13:18:18 · 130 阅读 · 0 评论