PAT甲级
文章平均质量分 73
XdpCs
https://github.com/XdpCs
展开
-
PAT甲级 1088 Rational Arithmetic (20 分)
For 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 file contains one test case, which gives in one line the two rational numbers in t原创 2021-08-31 18:29:55 · 141 阅读 · 0 评论 -
PAT甲级 1004 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 with a line containing 0<N<100, the number of nodes原创 2021-08-29 23:17:28 · 156 阅读 · 0 评论 -
PAT甲级 1057 Stack (30 分)
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 position) and Pop (deleting the top element). Now you are supposed to im原创 2021-08-29 22:37:22 · 189 阅读 · 0 评论 -
PAT甲级 1136 A Delayed Palindrome (20 分)
Consider a positive integer N written in standard notation with k+1 digits ai as ak⋯a1a0 with 0≤ai<10 for all i and ak>0. Then N is palindromic if and only if ai=ak−i for all i. Zero is written 0 and is also palindromic by definition.Non-palindromic原创 2021-08-26 23:10:37 · 132 阅读 · 0 评论 -
PAT甲级 1056 Mice and Rice (25 分)
Mice and Rice is 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 pl原创 2021-08-25 22:49:38 · 158 阅读 · 0 评论 -
PAT甲级 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原创 2021-08-25 18:38:57 · 135 阅读 · 0 评论 -
PAT甲级 1097 Deduplication on a Linked List (25 分)
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or absolute value of its key equals K will be kept. At the m原创 2021-08-25 17:49:59 · 116 阅读 · 0 评论 -
PAT甲级 1081 Rational Sum (20 分)
Given 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 with a positive integer N (≤100), followed in the next line N rational number原创 2021-08-23 22:25:10 · 72 阅读 · 0 评论 -
PAT甲级 1022 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 number as its ID. Given any query from a reader, you are suppose原创 2021-08-20 06:00:23 · 90 阅读 · 0 评论 -
PAT甲级 1010 Radix (25 分)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive integers N1 and N2, your task is to find the radix of one num原创 2021-08-19 22:17:20 · 74 阅读 · 0 评论 -
PAT甲级 1100 Mars Numbers (20 分)
People on Mars count their numbers with base 13:Zero on Earth is called “tret” on Mars.The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, respectively.For the next higher digit, Mars people name原创 2021-08-18 23:41:54 · 109 阅读 · 0 评论 -
PAT甲级 1017 Queueing at Bank (25 分)
Suppose 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 behind the yellow line, until it is his/her turn to be served and there is a原创 2021-08-18 23:14:18 · 62 阅读 · 0 评论 -
PAT甲级 1024 Palindromic Number (25 分)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.Non-palindromic numbers can be paired with palindromic原创 2021-08-18 00:03:31 · 113 阅读 · 0 评论 -
PAT甲级 1071 Speech Patterns (25 分)
People often have a preference among synonyms of the same word. For example, some may prefer “the police”, while others may prefer “the cops”. Analyzing such patterns can help to narrow down a speaker’s identity, which is useful when validating, for exampl原创 2021-08-16 22:44:25 · 165 阅读 · 0 评论 -
PAT甲级 1052 Linked List Sorting (25 分)
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list, you are supposed to sort the structures原创 2021-08-15 23:57:38 · 62 阅读 · 0 评论 -
PAT甲级 1023 Have Fun with Numbers (20 分)
Notice 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-digit number consisting exactly the numbers from 1 to 9, only in a diffe原创 2021-08-15 00:36:54 · 117 阅读 · 0 评论 -
PAT甲级 1015 Reversible Primes (20 分)
A 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 37 is also a prime.Now given any two positive integers N (<105) and原创 2021-08-14 16:56:38 · 86 阅读 · 0 评论 -
PAT甲级 1074 Reversing Linked List (25 分)
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→4; if K=4, you must output 4→3→2→1→5→6.Input Specification:Each原创 2021-08-11 23:59:52 · 96 阅读 · 0 评论 -
PAT甲级 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 B,原创 2021-08-10 21:58:32 · 125 阅读 · 0 评论 -
PAT甲级 1116 Come on! Let‘s 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原创 2021-08-10 21:33:57 · 135 阅读 · 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 for k times.Now given a resulting string on screen, you are supposed to list all the po原创 2021-08-10 20:18:51 · 77 阅读 · 0 评论 -
PAT甲级 1108 Finding Average (20 分)
The 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 legal input is a real number in [−1000,1000] and is accurate up to no more th原创 2021-08-10 08:01:59 · 148 阅读 · 0 评论 -
PAT甲级 1147 Heaps (30 分)
In computer science, a heap is 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原创 2021-08-09 17:35:37 · 106 阅读 · 0 评论 -
PAT甲级 1155 Heap Paths (30 分)
In computer science, a heap is 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原创 2021-08-08 22:08:17 · 124 阅读 · 0 评论 -
PAT甲级 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, T for the top level, A for advance and B for basic;the 2nd - 4th digits are the test site number, ranged from 101 to 999;the 5th - 10th digits give原创 2021-08-08 20:02:22 · 348 阅读 · 0 评论 -
PAT甲级 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原创 2021-08-08 18:31:43 · 118 阅读 · 0 评论 -
PAT甲级 1020 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 corresponding binary tree.Input Specification:Each input原创 2021-07-27 16:39:11 · 90 阅读 · 0 评论 -
PAT甲级 1032 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, and are stored as showed in Figure 1.loading beingFig原创 2021-07-23 22:14:36 · 140 阅读 · 0 评论 -
PAT甲级 1063 Set Similarity (25 分)
Given two sets of integers, the similarity of the sets is defined to be Nc/Nt×100%, where Nc is the number of distinct common numbers shared by the two sets, and Nt is the total number of distinct numbers in the two sets. Your job is to calculate the simil原创 2021-07-14 12:30:09 · 86 阅读 · 0 评论 -
PAT甲级 1059 Prime Factors (25 分)
Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1k1×p2k2×⋯×pmkm.Input Specification:Each input file contains one test case which gives a positive integer N in the range of long int.Outpu原创 2021-07-10 23:47:40 · 79 阅读 · 0 评论 -
PAT甲级 1054 The Dominant Color (20 分)
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. A strictly dominant color takes more than原创 2021-07-09 21:40:09 · 84 阅读 · 0 评论 -
PAT甲级 1047 Student List for Course (25 分)
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. For原创 2021-07-09 21:27:32 · 79 阅读 · 0 评论 -
PAT甲级 1039 Course List for Student (25 分)
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 for a query.Input Specification:Each input file contai原创 2021-07-09 20:57:07 · 81 阅读 · 0 评论 -
PAT甲级 1104 Sum of Number Segments (20 分)
Given 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.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4)原创 2021-07-09 20:38:18 · 77 阅读 · 0 评论 -
PAT甲级 1038 Recover the Smallest Number (30 分)
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-3214-0229-87 or 0229-32-87-321-3214 with respect to different ord原创 2021-07-09 19:36:23 · 90 阅读 · 0 评论 -
PAT甲级 1069 The Black Hole of Numbers (20 分)
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原创 2021-07-09 19:11:40 · 82 阅读 · 0 评论 -
PAT甲级 1093 Count PAT‘s (25 分)
The string APPAPT contains two PAT's as substrings. The first one is formed by the 2nd, the 4th, and the 6th characters, and the second one is formed by the 3rd, the 4th, and the 6th characters.Now given any string, you are supposed to tell the number of原创 2021-07-08 23:51:56 · 94 阅读 · 0 评论 -
PAT甲级 1095 Cars on Campus (30 分)
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原创 2021-07-05 22:30:55 · 136 阅读 · 0 评论 -
1128 N Queens Puzzle (20 分)
The “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 share the same row, column, or diagonal. The eight queens puzzle is an examp原创 2021-07-02 23:02:07 · 144 阅读 · 1 评论 -
PAT甲级 1080 Graduate Admission (30 分)
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 grad原创 2021-07-01 22:42:31 · 88 阅读 · 0 评论