PAT
文章平均质量分 75
情书、
你很少能赢,但偶尔也会。
展开
-
PAT 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’s preference by the number of times that an item has been accessed by this user.Input Spe原创 2021-03-03 19:21:13 · 154 阅读 · 1 评论 -
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-02-23 21:26:21 · 87 阅读 · 0 评论 -
PAT 1051 Pop Sequence (25 分)
Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, if M is 5 and N is 7, we can obtain原创 2021-02-23 17:44:06 · 114 阅读 · 0 评论 -
PAT 1049 Counting Ones (30 分)
The task is simple: given any positive integer N, you are supposed to count the total number of 1’s in the decimal form of the integers from 1 to N. For example, given N being 12, there are five 1’s in 1, 10, 11, and 12.Input Specification:Each input fil原创 2021-02-17 20:49:31 · 75 阅读 · 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-02-17 13:40:02 · 57 阅读 · 0 评论 -
PAT 1046 Shortest Distance (20 分)
The task is really simple: given N exits 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 file contains one test case. For each case, the first line contains原创 2021-02-17 11:47:23 · 63 阅读 · 0 评论 -
PAT 1044 Shopping in Mars (25 分)
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 the原创 2021-02-16 12:20:36 · 77 阅读 · 0 评论 -
PAT 1043 Is It a Binary Search Tree (25 分)
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 right subtree of a node contains only nodes with keys greater than原创 2021-02-15 17:44:16 · 78 阅读 · 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-02-14 10:03:01 · 68 阅读 · 0 评论 -
PAT 1034 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 between A and B, we say that A and B is related. The weight of a relation is defined to be the total time length of all the phone calls made between原创 2021-02-11 11:30:40 · 102 阅读 · 0 评论 -
PAT 1033 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 gas station may give different price. You are asked to car原创 2021-02-09 10:15:59 · 78 阅读 · 1 评论 -
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, loading and being are stored as showed in Figure 1.Fig原创 2021-02-07 11:49:20 · 63 阅读 · 0 评论 -
PAT 1025 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 will be merged immediately after the test. Now it is your原创 2021-02-05 22:13:46 · 69 阅读 · 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-02-05 09:35:06 · 78 阅读 · 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-02-04 13:11:57 · 78 阅读 · 0 评论 -
PAT 1021 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 is called the deepest root.Input Specification:Each in原创 2021-02-04 09:36:45 · 55 阅读 · 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-01-14 21:03:42 · 111 阅读 · 0 评论 -
PAT 1019 General Palindromic Number (20分)
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.Although palindromic numbers are most often considered原创 2021-01-09 20:41:52 · 64 阅读 · 0 评论 -
PAT 1016 Phone Bills (25分)
A 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 call is made. When a customer starts connecting a long-distance call, the t原创 2021-01-01 20:10:05 · 111 阅读 · 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 (<10^5 ) a原创 2020-12-29 20:51:25 · 84 阅读 · 0 评论 -
PAT 1013 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 need to repair any other highways to keep the rest of the c原创 2020-12-29 19:59:06 · 106 阅读 · 0 评论 -
PAT 1012 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), and E - English. At the mean time, we encourage students by emphasi原创 2020-12-27 02:41:08 · 206 阅读 · 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原创 2020-12-25 21:47:05 · 93 阅读 · 0 评论 -
PAT 1009 Product of Polynomials (25分)
This time, you are supposed to find A×B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:K N1 aN1 N2 aN2… NK aNK where K is原创 2020-12-23 21:08:55 · 69 阅读 · 0 评论 -
PAT 1006 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 are supposed to find the ones who have unlocked and loc原创 2020-12-22 22:12:01 · 70 阅读 · 0 评论 -
PAT 1005 Spell It Right (20分)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one test case. Each case occupies one line which contains an N (≤10^100).O原创 2020-12-22 20:54:20 · 101 阅读 · 0 评论 -
PAT 1004 Counting Leaves (30分)
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&原创 2020-12-22 19:39:19 · 79 阅读 · 0 评论 -
PAT 1003 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 length of each road between any pair of cities are marked原创 2020-12-21 21:43:32 · 101 阅读 · 0 评论 -
PAT 1002 A+B for Polynomials (25分)
This time, you are supposed to find A+B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:K N1 aN1 N2 aN2 …原创 2020-12-20 22:48:44 · 82 阅读 · 0 评论 -
PAT 1001 A+B Format (20分)
PAT 1001 A+B Format (20分)Calculate a+b and 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 file contains one test case. Each原创 2020-12-20 20:31:19 · 89 阅读 · 0 评论