
PAT甲级
文章平均质量分 94
ZCAIHUI_
卷又卷不过,躺又躺不平
展开
-
1034 Head of a Gang (30point(s))
One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call betweenAandB, we say thatAandBis related. The weight of a relation is defined to be t...原创 2020-04-04 19:18:36 · 255 阅读 · 0 评论 -
静态链表常见题型总结
静态链表首先,静态链表的原理是Hash,即通过建立一个结构体数组,使用下标去访问数组元素;一般化步骤:1)定义静态链表struct Node{ int add;//节点地址 typedef data;//数据域 int next;//指针域 XXX ; // 节点某性质,具体问题,具体分析}node[maxn];2) 静态链表初始化fo...原创 2019-12-26 21:10:55 · 466 阅读 · 0 评论 -
1109 Group Photo (25 point(s))
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 inte...原创 2019-08-17 23:06:55 · 151 阅读 · 0 评论 -
1153 Decode Registration Card of PAT (25 point(s))
A registration card number of PAT consists of 4 parts:the 1st letter represents the test level, namely,Tfor the top level,Afor advance andBfor basic; the 2nd - 4th digits are the test site nu...原创 2019-08-12 19:36:17 · 200 阅读 · 0 评论 -
1129 Recommendation Systems (25 point(s))
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 time...原创 2019-08-15 21:15:19 · 199 阅读 · 0 评论 -
1080 Graduate Admission (30 point(s))
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...原创 2019-08-20 21:09:56 · 226 阅读 · 0 评论 -
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 ga...原创 2019-08-24 22:06:33 · 188 阅读 · 0 评论 -
1049 Counting Ones (30 分)
The task is simple: given any positive integerN, you are supposed to count the total number of 1's in the decimal form of the integers from 1 toN. For example, givenNbeing 12, there are five 1's i...原创 2019-08-24 17:01:21 · 195 阅读 · 0 评论 -
1056 Mice and Rice (25 point(s))
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...原创 2019-08-11 16:41:57 · 204 阅读 · 0 评论 -
1108 Finding Average (20 分)
The basic task is simple: givenNreal numbers, you are supposed to calculate their average. But what makes it complicated is that some of the input numbers might not be legal. Alegalinput is a real ...原创 2019-08-23 19:24:30 · 445 阅读 · 0 评论 -
1103 Integer Factorization (30 分)
TheK−Pfactorization of a positive integerNis to writeNas the sum of theP-th power ofKpositive integers. You are supposed to write a program to find theK−Pfactorization ofNfor any positive...原创 2019-08-23 17:09:12 · 312 阅读 · 0 评论 -
1105 Spiral Matrix (25 分)
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...原创 2019-08-14 20:19:41 · 294 阅读 · 0 评论 -
1113 Integer Set Partition (25 point(s))
Given a set ofN(>1) positive integers, you are supposed to partition them into two disjoint setsA1andA2ofn1andn2numbers, respectively. LetS1andS2denote the sums of a...原创 2019-08-10 09:54:23 · 223 阅读 · 1 评论 -
7-4 Structure of a Binary Tree (30 分)
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, a binary tree can be uniquely determined.Now given a sequence of state...原创 2019-08-21 23:15:16 · 524 阅读 · 0 评论 -
1114 Family Property (25 point(s))
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 f...原创 2019-08-17 18:24:30 · 191 阅读 · 0 评论 -
1112 Stucked Keyboard (20 point(s))
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 forktimes.Now given a resulti...原创 2019-08-17 20:27:15 · 213 阅读 · 0 评论 -
1145 Hashing - Average Search Time (25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...原创 2019-09-02 21:05:48 · 297 阅读 · 0 评论 -
1146 Topological Order (25 分)
This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a topological order obtained from the given directed graph? Now you are supposed to write a program to test...原创 2019-09-02 20:34:29 · 269 阅读 · 0 评论 -
1111 Online Map (30 分)
Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other is the fastest. It is g...原创 2019-09-02 00:25:14 · 160 阅读 · 0 评论 -
1119 Pre- and Post-order Traversals (30 分)
2月4号:update版本~Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences, or preor...原创 2019-09-01 17:33:28 · 198 阅读 · 1 评论 -
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 a...原创 2019-08-29 20:27:26 · 165 阅读 · 0 评论 -
1141 PAT Ranking of Institutions (25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.Input Specification:Each input file conta...原创 2019-08-27 21:18:23 · 165 阅读 · 0 评论 -
1014 Waiting in Line (30 分)
Suppose a bank hasNwindows 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...转载 2019-08-26 23:10:21 · 227 阅读 · 0 评论 -
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...原创 2019-08-26 21:20:25 · 184 阅读 · 0 评论 -
1101 Quick Sort (25 分)
There is a classical process namedpartitionin the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its le...原创 2019-08-22 23:44:10 · 163 阅读 · 0 评论 -
1070 Mooncake (25 point(s))
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 ...原创 2019-08-18 10:42:09 · 163 阅读 · 0 评论 -
1110 Complete Binary Tree (25 point(s))
Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line gives a positive integerN(≤20) wh...原创 2019-08-09 12:56:15 · 197 阅读 · 0 评论 -
1123 Is It a Complete AVL Tree (30 point(s))
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...原创 2019-08-09 10:29:51 · 162 阅读 · 0 评论 -
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 Po...原创 2019-04-26 00:11:41 · 223 阅读 · 0 评论 -
1137 Final Grading (25 point(s))
For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from...原创 2019-04-14 00:11:01 · 205 阅读 · 0 评论 -
1087 All Roads Lead to Rome (30 point(s))
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 ...原创 2019-04-09 11:49:59 · 249 阅读 · 0 评论 -
1115 Counting Nodes in a BST (30 point(s))(创建BST,DFS统计每层结点个数)
1115Counting Nodes in a BST(30point(s))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 ...原创 2019-04-03 10:54:15 · 179 阅读 · 0 评论 -
1127 ZigZagging on a Tree (30 point(s)) (中序、后序建树and dfs深搜)
1127ZigZagging on a Tree(30point(s))Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder trav...原创 2019-04-08 08:57:43 · 193 阅读 · 0 评论 -
1099 Build A Binary Search Tree (30 point(s))
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 su...原创 2019-04-02 09:38:01 · 224 阅读 · 0 评论 -
1094 The Largest Generation (25 point(s))
A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation with the largest population.Input ...原创 2019-04-10 22:51:01 · 159 阅读 · 0 评论 -
1138 Postorder Traversal (25 point(s))(前序中序输出后序&不建树)
Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...原创 2019-04-04 07:30:43 · 220 阅读 · 0 评论 -
1148 Werewolf - Simple Version
1148 Werewolf - Simple Version(20 point(s))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...原创 2018-09-10 22:48:27 · 618 阅读 · 1 评论 -
1150 Travelling Salesman Problem
1150 Travelling Salesman Problem(25 point(s)) The “travelling salesman problem” asks the following question: “Given a list of cities and the distances between each pair of cities, what is the shortes...原创 2018-09-09 18:29:47 · 275 阅读 · 0 评论 -
1149 Dangerous Goods Packaging(25 point(s))
1149 Dangerous Goods Packaging(25 point(s))原创 2018-09-09 15:55:06 · 236 阅读 · 0 评论 -
1063 Set Similarity (25 point(s))
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 d...原创 2019-04-14 22:57:20 · 163 阅读 · 0 评论