
PAT
PAT甲级试题
zbchenchanghao
这个作者很懒,什么都没留下…
展开
-
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 S...原创 2020-02-21 10:15:24 · 114 阅读 · 0 评论 -
1046 Shortest Distance (20分)
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 file conta...原创 2020-02-21 09:56:14 · 101 阅读 · 0 评论 -
1053 Path of Equal Weight (30分)
Given a non-empty tree with rootR, and with weightWiassigned to each tree nodeTi. Theweight of a path fromRtoLis defined to be the sum of the weights of all the nodes along the path fro...原创 2020-02-19 09:27:22 · 88 阅读 · 0 评论 -
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 integerkeyand aNextpointer to the next structure. Now give...原创 2020-02-19 06:21:08 · 118 阅读 · 0 评论 -
1051 Pop Sequence (25分)
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 th...原创 2020-02-19 05:05:56 · 101 阅读 · 0 评论 -
1050 String Subtraction (20分)
Given two stringsS1andS2,S=S1−S2is defined to be the remaining string after taking all the characters inS2fromS1. Your task is simply to calculateS1−S2for any given s...原创 2020-02-19 03:24:04 · 83 阅读 · 0 评论 -
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 Po...原创 2020-02-18 12:06:02 · 93 阅读 · 0 评论 -
1056 Mice and Rice (25分)
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...原创 2020-02-18 06:33:59 · 102 阅读 · 0 评论 -
1055 The World's Richest (25分)
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 peopl...原创 2020-02-18 02:36:46 · 125 阅读 · 1 评论 -
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 d...原创 2020-02-18 02:15:55 · 100 阅读 · 0 评论 -
1060 Are They Equal (25分)
If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as0.123×105with simple chopping. Now given the number of signif...原创 2020-02-17 02:10:03 · 149 阅读 · 0 评论 -
1059 Prime Factors (25分)
Given any positive integerN, you are supposed to find all of its prime factors, and write them in the formatN=p1k1×p2k2×⋯×pmkm.Input Specification:Each input file co...原创 2020-02-17 00:38:39 · 107 阅读 · 0 评论 -
1058 A+B in Hogwarts (20分)
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 Si...原创 2020-02-17 00:00:58 · 122 阅读 · 0 评论 -
1064 Complete Binary Search Tree (30分)
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 s...原创 2020-02-16 06:52:21 · 110 阅读 · 0 评论 -
1063 Set Similarity (25分)
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 ...原创 2020-02-16 03:28:51 · 83 阅读 · 0 评论 -
1062 Talent and Virtue (25分)
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 virt...原创 2020-02-16 03:05:04 · 98 阅读 · 0 评论 -
1061 Dating (20分)
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...原创 2020-02-16 02:29:33 · 93 阅读 · 0 评论 -
1068 Find More Coins (30分)(背包问题DP / DFS)
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,...原创 2020-02-15 10:29:50 · 353 阅读 · 0 评论 -
1067 Sort with Swap(0, i) (25分)
Given any permutation of the numbers {0, 1, 2,...,N−1}, it is easy to sort them in increasing order. But what ifSwap(0, *)is the ONLY operation that is allowed to use? For example, to sort {4, 0, 2...原创 2020-02-15 03:24:37 · 121 阅读 · 0 评论 -
1066 Root of AVL Tree (25分)
An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is...原创 2020-02-14 23:16:20 · 102 阅读 · 0 评论 -
1065 A+B and C (64bit) (20分)
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). The...原创 2020-02-14 22:02:34 · 107 阅读 · 1 评论 -
1072 Gas Station (30分)
A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou...原创 2020-02-14 07:09:44 · 125 阅读 · 0 评论 -
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...原创 2020-02-14 04:34:04 · 90 阅读 · 0 评论 -
1070 Mooncake (25分)(神坑)
Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now ...原创 2020-02-14 03:31:07 · 143 阅读 · 0 评论 -
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 takin...原创 2020-02-14 02:58:30 · 99 阅读 · 0 评论 -
1076 Forwards on Weibo (30分)
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a ...原创 2020-02-13 08:58:01 · 121 阅读 · 0 评论 -
1075 PAT Judge (25分)(坑多,填坑)
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-02-13 06:29:11 · 231 阅读 · 2 评论 -
1074 Reversing Linked List (25分)
Given a constantKand a singly linked listL, you are supposed to reverse the links of everyKelements onL. For example, givenLbeing 1→2→3→4→5→6, ifK=3, then you must output 3→2→1→6→5→4; ifK=4, ...原创 2020-02-13 02:08:41 · 118 阅读 · 0 评论 -
1073 Scientific Notation (20分)
Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+-][1-9].[0-9]+E[+-][0-9]+ which means that the inte...原创 2020-02-12 23:42:32 · 98 阅读 · 0 评论 -
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...原创 2020-02-12 05:23:14 · 110 阅读 · 0 评论 -
1079 Total Sales of Supply Chain (25分)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on th...原创 2020-02-12 03:34:42 · 82 阅读 · 0 评论 -
1078 Hashing (25分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined to beH(key)=key%TSiz...原创 2020-02-12 00:11:47 · 122 阅读 · 0 评论 -
1077 Kuchiguse (20分)
The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker's personality. Such a preference is called ...原创 2020-02-11 23:07:34 · 98 阅读 · 0 评论 -
1083 List Grades (25分)
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 ...原创 2020-02-11 22:35:03 · 81 阅读 · 0 评论 -
1082 Read Number in Chinese (25分)
Given an integer with no more than 9 digits, you are supposed to read it in the traditional Chinese way. OutputFufirst if it is negative. For example, -123456789 is read asFu yi Yi er Qian san Bai ...原创 2020-02-11 22:16:24 · 89 阅读 · 0 评论 -
1081 Rational Sum (20分)
GivenNrational numbers in the formnumerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case starts with a positive int...原创 2020-02-10 22:09:30 · 79 阅读 · 0 评论 -
1087 All Roads Lead to Rome (30分)
Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:Each ...原创 2020-02-10 03:17:17 · 87 阅读 · 0 评论 -
1086 Tree Traversals Again (25分)
An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac...原创 2020-02-09 22:21:45 · 152 阅读 · 0 评论 -
1085 Perfect Sequence (25分)
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, respecti...原创 2020-02-09 20:15:08 · 82 阅读 · 0 评论 -
1084 Broken Keyboard (20分)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.Now given a string that you are supposed to...原创 2020-02-09 19:36:59 · 75 阅读 · 0 评论