![](https://img-blog.csdnimg.cn/20190927151132530.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
PAT·甲-题解
文章平均质量分 78
https://pintia.cn/problem-sets/994805342720868352/exam/problems/type/7
逆行的炸酱面
一斤代码十撮头发
展开
-
「1015」Reversible Primes
➳ENTRYA 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 reverse...原创 2022-03-15 15:10:43 · 83 阅读 · 0 评论 -
「1014」Waiting in Line
➳ENTRYSuppose a bank has windows 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 ...原创 2022-03-15 22:35:11 · 46 阅读 · 0 评论 -
「1013」Battle Over Cities
➳ENTRYIt 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 immed...原创 2022-03-12 19:45:02 · 47 阅读 · 0 评论 -
「1012」The Best Rank
➳ENTRYTo 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 Algrb...原创 2022-03-03 17:21:04 · 53 阅读 · 0 评论 -
「1017」Queueing at Bank
➳ENTRYSuppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behi...原创 2022-04-08 22:00:16 · 79 阅读 · 0 评论 -
「1022」Digital Library
➳ENTRYA 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 ...原创 2022-07-06 20:59:46 · 38 阅读 · 0 评论 -
「1021」Deepest Root
➳ENTRYA 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 tr...原创 2022-07-05 09:27:29 · 28 阅读 · 0 评论 -
「1025」PAT Ranking
➳ENTRYProgramming 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...原创 2022-07-17 10:06:20 · 29 阅读 · 0 评论 -
「1016」Phone Bills
➳ENTRYA long-distance telephone company charges its customers by the following rules:Making a long-distance call costs a certain amount per minute, depending on the time of day when the cal...原创 2022-04-04 06:30:41 · 95 阅读 · 0 评论 -
「1026」Table Tennis
➳ENTRYA 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 ass...原创 2022-07-19 18:45:51 · 34 阅读 · 0 评论 -
「1020」Tree Traversals
➳ENTRYSuppose 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 seq...原创 2022-07-04 14:31:24 · 79 阅读 · 0 评论 -
「1024」Palindromic Number
➳ENTRYA 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 pal...原创 2022-07-17 05:40:41 · 62 阅读 · 0 评论 -
「1023」Have Fun with Numbers
➳ENTRYNotice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-...原创 2022-07-07 20:38:24 · 64 阅读 · 0 评论 -
「1018」Public Bike Management
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 station...原创 2022-04-13 09:53:29 · 111 阅读 · 0 评论 -
「1044」Shopping in Mars
Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any ...原创 2022-08-23 23:24:29 · 30 阅读 · 0 评论 -
「1031」Hello World for U
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...原创 2022-07-21 12:31:17 · 21 阅读 · 0 评论 -
「1039」Course List for Student
Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student w...原创 2022-08-20 17:41:06 · 22 阅读 · 0 评论 -
「1043」Is It a Binary Search Tree
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 with keys less than the node’s key.The ...原创 2022-08-22 02:45:20 · 34 阅读 · 0 评论 -
「1036」Boys vs Girls
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification:Each input file contai...原创 2022-08-05 17:36:22 · 30 阅读 · 0 评论 -
「1033」To Fill or Not to Fill
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. Dif...原创 2022-08-01 11:35:21 · 27 阅读 · 0 评论 -
「1035」Password
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) f...原创 2022-08-02 08:08:21 · 24 阅读 · 0 评论 -
「1042」Shuffling Machine
Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid “inside jobs” where employees collaborate wit...原创 2022-08-21 13:42:44 · 31 阅读 · 0 评论 -
「1041」Be Unique
Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,104]. The first one who ...原创 2022-08-20 08:29:27 · 30 阅读 · 0 评论 -
「1037」Magic Coupon
The magic shop in Mars is offering some magic coupons. Each coupon has an integerNprinted on it, meaning that when you use this coupon with a product, you may getNtimes the value of that ...原创 2022-08-05 03:14:04 · 24 阅读 · 0 评论 -
「1029」Median
➳ENTRYGiven an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1 = { 11, 12, 13, 14 } is 12, and the median of S2 = { 9, 10,...原创 2022-07-20 16:08:23 · 36 阅读 · 0 评论 -
「1028」List Sorting
➳ENTRYExcel 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 li...原创 2022-07-20 13:41:22 · 27 阅读 · 0 评论 -
「1030」Travel Plan
➳ENTRYA 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...原创 2022-07-21 03:22:05 · 43 阅读 · 0 评论 -
「1032」Sharing
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...原创 2022-08-01 08:09:09 · 19 阅读 · 0 评论 -
「1034」Head of a Gang
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 define...原创 2022-08-02 02:09:02 · 110 阅读 · 0 评论 -
「1045」Favorite Color Stripe
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 remain...原创 2022-08-23 22:36:03 · 82 阅读 · 0 评论 -
「1038」Recover the Smallest Number
Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-...原创 2022-08-19 05:48:02 · 127 阅读 · 0 评论 -
「1040」Longest Symmetric String
Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, givenIs PAT&TAP symmetric?, the longest symmetric sub-string iss PAT&TAP s, h...原创 2022-08-20 00:32:09 · 104 阅读 · 0 评论 -
「1051」Pop Sequence
Given a stack which can keepMnumbers at most. PushNnumbers in the order of 1, 2, 3, …,Nand pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequen...原创 2022-09-01 12:50:33 · 43 阅读 · 0 评论 -
「1052」Linked List Sorting
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integerkeyand aNextpointer to the next structure....原创 2022-09-02 23:55:16 · 60 阅读 · 0 评论 -
「1060」Are They Equal
If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved aswith simple chopping. Now given the number of significa...原创 2022-09-11 23:23:34 · 116 阅读 · 0 评论 -
「1057」Stack
Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the top positio...原创 2022-09-08 14:26:02 · 24 阅读 · 0 评论 -
「1058」A+B in Hogwarts
If 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 twenty-nine Knuts...原创 2022-09-08 00:39:25 · 23 阅读 · 0 评论 -
「1062」Talent and Virtue
About 900 years ago, a Chinese philosopher Sima Guang wrote a history book in which he talked about people’s talent and virtue. According to his theory, a man being outstanding in both talent...原创 2022-09-21 23:19:04 · 112 阅读 · 0 评论 -
「1046」Shortest Distance
The task is really simple: givenNexits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input fi...原创 2022-08-26 18:36:27 · 65 阅读 · 0 评论 -
「1048」Find Coins
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments....原创 2022-08-31 10:58:22 · 36 阅读 · 0 评论