![](https://img-blog.csdnimg.cn/20190927151026427.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
PAT 甲级 C/C++
PAT
棉毛裤穿吗
而我们终将回归那片太初的花海
展开
-
10.1 PAT 甲级 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 position for only once and some of the diamonds are taken off th.原创 2020-10-01 09:48:10 · 111 阅读 · 0 评论 -
9.28 PAT 甲级 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 sequence of the stack. For example, ifMis 5 andNis 7, we can obta...原创 2020-09-28 08:16:11 · 92 阅读 · 0 评论 -
9.28 PAT 甲级 1085 Perfect Sequence
Given a sequence of positive integers and another positive integerp. The sequence is said to be aperfect sequenceifM≤m×pwhereMandmare the maximum and minimum numbers in the sequence, respectively.Now given a sequence and a parameterp, you are s...原创 2020-09-28 08:01:09 · 96 阅读 · 0 评论 -
9.26 PAT 甲级 1091 Acute Stroke
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the stroke core.Input Specifica原创 2020-09-26 10:46:29 · 63 阅读 · 0 评论 -
9.12 PAT 甲级 1063 Set Similarity
Given two sets of integers, the similarity of the sets is defined to beNc/Nt×100%, whereNcis the number of distinct common numbers shared by the two sets, andNtis the total number of distinct numbers in the two sets. Your job is to calcula...原创 2020-09-12 12:28:33 · 90 阅读 · 0 评论 -
9.9 PAT 1065 A+B and C (64bit)
Given three integersA,BandCin [−263,263], you are supposed to tell whetherA+B>C.Input Specification:The first line of the input gives the positive number of test cases,T(≤10). ThenTtest cases follow, each consists of a single line co...原创 2020-09-09 09:32:12 · 78 阅读 · 0 评论 -
9.9 PAT 1147 Heaps
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-09-09 09:07:22 · 104 阅读 · 0 评论 -
9.9 PAT 甲级 Recommendation System
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-09-09 00:11:13 · 76 阅读 · 0 评论 -
9.8 PAT 1128 N Queens Puzzle
The "eight queens puzzle" is the problem of placing eight chess queens on an8×8chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal. The eight queens puzzle is an examp..原创 2020-09-08 22:12:54 · 85 阅读 · 0 评论 -
9.6 PAT 甲级 1109 Group Photo
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-09-06 08:52:57 · 121 阅读 · 0 评论 -
9.4 PAT 甲级 1105 Spiral Matrix
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-09-04 02:01:28 · 112 阅读 · 0 评论 -
9.2 PAT 甲级 1095 Cars on Campus
Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you are supposed to tell, at any specific time point, the num原创 2020-09-02 13:13:46 · 114 阅读 · 0 评论 -
9.1 PAT 甲级 1083 List Grades
Given a list ofNstudent records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.Input Specification:Each inp..原创 2020-09-01 09:45:44 · 109 阅读 · 0 评论 -
8.31 PAT 甲级 1080 Graduate Admission
It is said that in 2011, there are about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the admission procedure.Each applicant will have to provide two gra原创 2020-09-01 00:03:42 · 124 阅读 · 0 评论 -
8.30 PAT 甲级 1069 The Black Hole of Numbers
For 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 number can be obtained by taking the second number from the first one. Repeat in this m原创 2020-08-30 23:25:34 · 110 阅读 · 0 评论 -
8.29 PAT 甲级 1054 The Dominant Color
Behind 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 proportional area is called the dominant color. Astrictlydominant color takes more than..原创 2020-08-29 20:31:16 · 73 阅读 · 0 评论 -
8.29 PAT 甲级 1047 Student List for Course
Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.Input Specification:Each input file contains one test case. F原创 2020-08-29 14:22:15 · 97 阅读 · 0 评论 -
8.29 PAT 甲级 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 bets on a unique number wins. For example, if there are 7 peop原创 2020-08-29 07:49:00 · 93 阅读 · 0 评论 -
8.28 PAT 甲级 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 printed in the original order, starting top-down from the le...原创 2020-08-28 22:16:16 · 100 阅读 · 0 评论 -
8.28 PAT 甲级 1008 Elevator
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 seconds to move the elevator up one floor, and 4 seconds to..原创 2020-08-28 21:00:47 · 87 阅读 · 0 评论 -
8.27 PAT 甲级 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 and virtue must be a "sage(圣人)"; being less excellent but with o原创 2020-08-27 16:52:38 · 126 阅读 · 0 评论 -
8.25 PAT 甲级 1048 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 with gamblers by performing inadequate shuffles, many casinos employ原创 2020-08-25 10:03:24 · 72 阅读 · 0 评论 -
8.24 PAT 甲级 1092 To Buy or Not to Buy
Eva 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 of the shop would only sell the strings in whole pieces. Hence Eva must check whet原创 2020-08-24 09:06:01 · 128 阅读 · 0 评论 -
8.24 PAT 甲级 1011 World Cup Betting
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. Similarly, football betting fans were putting their money原创 2020-08-24 08:35:29 · 96 阅读 · 0 评论 -
8.22 PAT 甲级 1056 Mice and Rice
Mice and Riceis the name of a programming contest in which each programmer must write a piece of code to control the movements of a mouse in a given map. The goal of each mouse is to eat as much rice as possible in order to become a FatMouse.First the p.原创 2020-08-22 17:20:46 · 84 阅读 · 0 评论 -
8.21 PAT 甲级 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 product back! What is more, the shop also offers some bonus produ...原创 2020-08-21 08:44:37 · 82 阅读 · 0 评论 -
8.20 PAT 甲级 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 #2 is a werewolf."; player #2 said: "Player #3 is a human."; player #3 said: "Player #4 i原创 2020-08-20 10:09:43 · 115 阅读 · 0 评论 -
8.19 PAT 甲级 1015 The World‘s Richest
Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world's wealthiest people. Now you are supposed to simulate this job, but concentrate only on the people in a certain range of ages. That is, given the net wor原创 2020-08-19 15:05:43 · 94 阅读 · 0 评论 -
8.18 PAT 甲级 1114 Family Property
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-08-18 10:39:28 · 113 阅读 · 0 评论 -
7.21 PAT 甲级 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. However, there was a special requirement of the payment: for eac原创 2020-07-21 17:55:22 · 110 阅读 · 0 评论 -
6.23 PAT 甲级 1013 Battle Over Cities
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 need to repair any other highways to keep the rest of the c原创 2020-06-23 11:14:06 · 177 阅读 · 0 评论 -
6.2 PAT 甲级 1068 Find More 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. However, there was a special requirement of the payment: for eac原创 2020-06-02 19:01:11 · 153 阅读 · 0 评论 -
5.22 PAT 甲级 1007 Maximum Subsequence Sum
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 exampl...原创 2020-05-22 08:59:33 · 119 阅读 · 0 评论 -
4.20 PAT 甲级 1021 Deepest Root
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-04-20 11:09:33 · 165 阅读 · 0 评论 -
4.20 PAT 甲级 1020 Tree Traversals
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-04-20 09:44:07 · 153 阅读 · 0 评论 -
4.19 PAT 甲级 1004 Counting Leaves
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-04-19 10:14:03 · 104 阅读 · 0 评论 -
4.14 PAT 甲级 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. Now give...原创 2020-04-14 10:24:58 · 109 阅读 · 0 评论 -
4.13 PAT 甲级 1075 PAT Judge
The ranklist of PAT is generated from the status list, which shows the scores of the submissions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input file co...原创 2020-04-13 21:58:11 · 126 阅读 · 0 评论 -
4.13 PAT 甲级 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 who comes ...原创 2020-04-13 11:11:58 · 97 阅读 · 0 评论 -
4.13 PAT 甲级 1028 List Sorting
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-04-13 10:10:32 · 112 阅读 · 0 评论