PAT(Advanced Level) Practice
文章平均质量分 77
PAT (Advanced Level) Practice
追寻远方的人
你的职责是平整土地,而非焦虑时光。
展开
-
1061 Dating (20 point(s))
1061 Dating (20 point(s))Sherlock 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 strange strings are actually referring to the原创 2022-03-04 20:55:03 · 71 阅读 · 0 评论 -
1060 Are They Equal (25 point(s))
1060 Are They Equal (25 point(s))If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×105 with simple chopping. Now given the number of significant digits on a machine原创 2022-03-04 20:33:06 · 128 阅读 · 0 评论 -
1059 Prime Factors (25 point(s))
1059 Prime Factors (25 point(s))Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1k1×p2k2×⋯×pmk**m.Input Specification:Each input file contains one test case which gives a positive intege原创 2022-03-04 19:57:24 · 83 阅读 · 0 评论 -
1058 A+B in Hogwarts (20 point(s))
1058 A+B in Hogwarts (20 point(s))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 to a Sickle, it’s easy enough原创 2022-03-04 19:19:54 · 72 阅读 · 0 评论 -
1057 Stack (30 point(s))
1057 Stack (30 point(s))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). N原创 2022-03-04 19:08:09 · 91 阅读 · 0 评论 -
1056 Mice and Rice (25 point(s))
1056 Mice and Rice (25 point(s))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 t原创 2022-03-04 18:40:44 · 102 阅读 · 0 评论 -
1053 Path of Equal Weight (30 point(s))
1053 Path of Equal Weight (30 point(s))Given a non-empty tree with root R, and with weight W**i assigned to each tree node T**i. The weight of a path from *R* to *L* is defined to be the sum of the weights of all the nodes along the path from R to any lea原创 2022-03-03 15:59:14 · 196 阅读 · 0 评论 -
1052 Linked List Sorting (25 point(s))
1052 Linked List Sorting (25 point(s))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,原创 2022-03-03 09:50:09 · 81 阅读 · 0 评论 -
1049 Counting Ones (30 point(s))
1049 Counting Ones (30 point(s))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.In原创 2022-03-02 22:20:06 · 66 阅读 · 0 评论 -
1048 Find Coins (25 point(s))
1048 Find Coins (25 point(s))1048 Find Coins (25 point(s))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. Howe原创 2022-03-02 22:19:25 · 97 阅读 · 0 评论 -
1046 Shortest Distance (20 point(s))
1046 Shortest Distance (20 point(s))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. Fo原创 2022-03-02 22:18:15 · 71 阅读 · 0 评论 -
1045 Favorite Color Stripe (30 point(s))
1045 Favorite Color Stripe (30 point(s))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 remaining parts together to fo原创 2022-03-01 22:22:28 · 181 阅读 · 0 评论 -
1044 Shopping in Mars (25 分)
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 t原创 2022-01-05 12:09:22 · 161 阅读 · 0 评论 -
1043 Is It a Binary Search Tree (25 分)
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 co原创 2022-01-04 16:40:44 · 84 阅读 · 0 评论 -
1040 Longest Symmetric String (25 分)
1040 Longest Symmetric String (25 分)[Manacher]Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&TAP symmetric?, the longest symmetric sub-string is s PAT&TAP s, hence you must outp原创 2021-11-06 16:02:40 · 85 阅读 · 0 评论 -
1039 Course List for Student (25 分)
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 S原创 2021-10-27 22:15:10 · 86 阅读 · 0 评论 -
1038 Recover the Smallest Number (30 分)
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-8原创 2021-10-27 22:14:49 · 83 阅读 · 0 评论 -
1037 Magic Coupon (25) [贪⼼算法]
1037 Magic Coupon (25 分)The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product back! What is more, the shop als原创 2021-10-27 22:14:07 · 109 阅读 · 0 评论 -
1034 Head of a Gang (30 分)
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 t原创 2021-10-20 10:08:10 · 76 阅读 · 0 评论 -
1033 To Fill or Not to Fill (25 分)
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 di原创 2021-10-17 22:08:45 · 108 阅读 · 0 评论 -
1032 Sharing (25 分)
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 sho原创 2021-10-17 17:34:29 · 74 阅读 · 0 评论 -
1031 Hello World for U (20 分)
1031 Hello World for U (20 分)Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as:h de ll rlowoThat is, the characters must be printed in the original order, st原创 2021-10-15 21:26:15 · 74 阅读 · 0 评论 -
1030 Travel Plan (30 分)
1030 Travel Plan (30 分)A 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 shortest path between his/her starting city and原创 2021-10-10 16:52:15 · 72 阅读 · 0 评论 -
1029 Median (25 分)
1029 Median (25 分)Given 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, 15, 16, 17 } is 15. The median of two sequences is d原创 2021-10-09 14:51:05 · 86 阅读 · 0 评论 -
1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分)People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 digits for Green, and the last 2原创 2021-10-09 12:56:09 · 73 阅读 · 0 评论 -
1026 Table Tennis (30 分)
1026 Table Tennis (30 分)A 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 assigned to the available table with the smallest原创 2021-10-06 19:29:04 · 221 阅读 · 0 评论 -
1025 PAT Ranking (25 分)
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原创 2021-10-04 17:35:16 · 139 阅读 · 0 评论 -
1024 Palindromic Number (25 分)
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原创 2021-10-03 17:41:46 · 72 阅读 · 0 评论 -
1023 Have Fun with Numbers (20 分)
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 nu原创 2021-10-02 17:50:18 · 156 阅读 · 0 评论 -
1022 Digital Library (30 分)
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 fr原创 2021-09-30 20:52:21 · 73 阅读 · 0 评论 -
1021 Deepest Root (25 分)
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.Inp原创 2021-09-26 16:04:21 · 130 阅读 · 0 评论 -
1020 Tree Traversals (25 分)
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.Inpu原创 2021-09-26 12:30:28 · 96 阅读 · 0 评论 -
1018 Public Bike Management (30 分)
1018 Public Bike Management (30 分)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 stations in the city.The Public Bike原创 2021-09-23 20:14:08 · 210 阅读 · 0 评论 -
1017 Queueing at Bank (25 分)
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 tur原创 2021-09-22 15:47:15 · 73 阅读 · 0 评论 -
1016 Phone Bills (25 分)
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 l原创 2021-09-21 16:01:00 · 91 阅读 · 0 评论 -
1014 Waiting in Line (30 分)
1014 Waiting in Line (30 分)Suppose a bank has N 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 are:The space inside the yellow line in f原创 2021-09-20 09:13:21 · 75 阅读 · 0 评论 -
1013 Battle Over Cities (25 分)
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 hig原创 2021-09-19 17:10:27 · 95 阅读 · 0 评论 -
1012 The Best Rank (25 分)
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 enc原创 2021-09-18 14:51:27 · 143 阅读 · 0 评论 -
1010 Radix (25 分)
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 th原创 2021-09-17 11:20:33 · 111 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25 分)
1007 Maximum Subsequence Sum (25 分)Given a sequence of K integers { N1, N2, …, N**K }. A continuous subsequence is defined to be { N**i, N**i+1, …, N**j } where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum of it原创 2021-09-08 10:30:23 · 106 阅读 · 0 评论