![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PTA
文章平均质量分 84
负反馈循环
这个作者很懒,什么都没留下…
展开
-
PTA甲级 1033 To Fill or Not to Fill (C++)
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-09-09 11:30:51 · 75 阅读 · 0 评论 -
PTA甲级 1114 Family Property (C++)
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 family, and the average area and number of sets of their原创 2021-09-06 18:22:13 · 95 阅读 · 0 评论 -
PTA甲级 1135 Is It A Red-Black Tree (C++)
There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:(1) Every node is either red or black.(2) The root is black.(3) Every leaf (NULL) is black.(4) If a node is red, then both its原创 2021-09-06 13:43:51 · 207 阅读 · 0 评论 -
PTA甲级 1018 Public Bike Management (C++)
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 Management Center (PBMC) keeps mon原创 2021-09-06 10:54:13 · 114 阅读 · 0 评论 -
PTA甲级 1139 First Contact (C++)
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle in the early years. When a boy A had a crush on a girl B, he would usually not contact her directly in the first place. Instead, he might ask another boy C,原创 2021-09-05 12:12:46 · 1433 阅读 · 0 评论 -
PTA甲级 1091 Acute Stroke (C++)
One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the stroke core.Input Specificat原创 2021-09-04 16:42:58 · 79 阅读 · 0 评论 -
PTA甲级 1056 Mice and Rice (C++)
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-09-04 12:49:43 · 120 阅读 · 0 评论 -
PTA甲级 1148 Werewolf - Simple Version (C++)
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: “Player #2 is a werewolf.”;player #2 said: “Player #3 is a human.”;player #3 said: “Player #4 is原创 2021-09-04 11:43:46 · 266 阅读 · 0 评论 -
PTA甲级 1021 Deepest Root (C++)
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-09-03 22:07:04 · 143 阅读 · 0 评论 -
PTA甲级 1057 Stack (C++)
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-09-03 18:26:32 · 103 阅读 · 0 评论 -
PTA甲级 1095 Cars on Campus (C++)
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-09-03 13:27:18 · 106 阅读 · 0 评论 -
PTA甲级 1076 Forwards on Weibo (C++)
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 user makes a post on Weibo, all his/her followers can vi原创 2021-09-02 16:24:10 · 87 阅读 · 0 评论 -
PTA甲级 1094 The Largest Generation (C++)
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 Specification:Each input file contains one test case. Ea原创 2021-09-02 15:40:42 · 80 阅读 · 1 评论 -
PTA甲级 1030 Travel Plan (C++)
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 the destination. If suc原创 2021-09-02 11:37:13 · 92 阅读 · 0 评论 -
PTA甲级 1004 Counting Leaves (C++)
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<1000<N<1000<N&l原创 2021-09-02 11:13:32 · 73 阅读 · 0 评论 -
PTA甲级 1003 Emergency (C++)
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原创 2021-09-02 10:50:41 · 96 阅读 · 0 评论 -
PTA甲级 1087 All Roads Lead to Rome (C++)
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 input file contains one test case. For each case, the firs原创 2021-09-01 18:51:24 · 106 阅读 · 0 评论 -
PTA甲级 1046 Shortest Distance (C++)
The task is really simple: given NNN 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 contain原创 2021-09-01 17:10:34 · 65 阅读 · 0 评论 -
PTA甲级 1022 Digital Library (C++)
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-09-01 12:54:59 · 92 阅读 · 0 评论 -
PTA甲级 1134 Vertex Cover (C++)
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if each of them is a vertex cover or not.Input Specificatio原创 2021-09-01 11:00:43 · 106 阅读 · 0 评论 -
PTA甲级 1142 Maximal Clique (C++)
A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adjacent vertex. (Quoted from https://en.wikipedia.org/wiki原创 2021-09-01 10:40:18 · 83 阅读 · 0 评论 -
PTA甲级 1150 Travelling Salesman Problem (C++)
The “travelling salesman problem” asks the following question: “Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and returns to the origin city?” It is an NP-hard problem in com原创 2021-08-31 22:13:49 · 120 阅读 · 0 评论 -
PTA甲级 1103 Integer Factorization (C++)
The K−PK−PK−P factorization of a positive integer NNN is to write NNN as the sum of the PPP-th power of KKK positive integers. You are supposed to write a program to find the K−PK−PK−P factorization of NNN for any positive integers NNN, KKK and PPP.Input原创 2021-08-31 18:56:22 · 96 阅读 · 0 评论 -
PTA甲级 1151 LCA in a Binary Tree (C++)
The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.Given any two nodes in a binary tree, you are supposed to find their LCA.Input Specification:Each input file contains one test case.原创 2021-08-31 17:02:13 · 121 阅读 · 0 评论 -
PTA甲级 1154 Vertex Coloring (C++)
A proper vertex coloring is a labeling of the graph’s vertices with colors such that no two vertices sharing the same edge have the same color. A coloring using at most kkk colors is called a (proper) kkk-coloring.Now you are supposed to tell if a given c原创 2021-08-31 11:18:46 · 72 阅读 · 0 评论 -
PTA甲级 1155 Heap Paths (C++)
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-31 11:03:23 · 97 阅读 · 0 评论 -
PTA甲级 1153 Decode Registration Card of PAT (C++)
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-31 00:23:56 · 78 阅读 · 0 评论 -
PTA甲级 1152 Google Recruitment (C++)
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-30 21:55:17 · 514 阅读 · 0 评论 -
PTA甲级 1149 Dangerous Goods Packaging (C++)
When shipping goods with containers, we have to be careful not to pack some incompatible goods into the same container, or we might get ourselves in serious trouble. For example, oxidizing agent (氧化剂) must not be packed with flammable liquid (易燃液体), or it原创 2021-08-30 17:12:07 · 100 阅读 · 0 评论 -
PTA甲级 1147 Heaps (C++)
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-30 12:50:09 · 86 阅读 · 0 评论 -
PTA甲级 1146 Topological Order (C++)
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 each of the options.Input Specification:Each input f原创 2021-08-30 12:30:17 · 99 阅读 · 0 评论 -
PTA甲级 1145 Hashing - Average Search Time (C++)
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 search time (the number of comparisons made to find whether原创 2021-08-30 12:09:24 · 108 阅读 · 0 评论 -
PTA甲级 1144 The Missing Number (C++)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N(≤105)N (≤10^5)N(≤105). Then NNN in原创 2021-08-30 11:00:28 · 69 阅读 · 0 评论 -
PTA甲级 1143 Lowest Common Ancestor (C++)
The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node con原创 2021-08-30 00:48:39 · 92 阅读 · 0 评论 -
PTA甲级 1141 PAT Ranking of Institutions (C++)
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 contains one test case. For each case, the first line gives a p原创 2021-08-29 22:36:08 · 80 阅读 · 0 评论 -
PTA甲级 1140 Look-and-say Sequence (C++)
Look-and-say sequence is a sequence of integers as the following:D, D1, D111, D113, D11231, D112213111, ...where D is in [0, 9] except 1. The (n+1)st number is a kind of description of the nth number. For example, the 2nd number means that there is one原创 2021-08-29 18:30:56 · 114 阅读 · 0 评论 -
PTA甲级 1138 Postorder Traversal (C++)
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 sequence of the corresponding binary tree.Input Specifica原创 2021-08-29 17:58:24 · 97 阅读 · 0 评论 -
PTA甲级 1137 Final Grading (C++)
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 the online programming assignments, and then receive a原创 2021-08-29 14:21:47 · 71 阅读 · 0 评论 -
PTA甲级 1136 A Delayed Palindrome (C++)
Consider a positive integer NNN written in standard notation with k+1k+1k+1 digits aia_iai as ak⋯a1a0a_k⋯a_1a_0ak⋯a1a0 with 0≤ai<100≤a_i<100≤ai<10 for all iii and ak>0a_k>0ak>0. Then NNN is palindromic if and only if ai=ak−ia_i=a_{k原创 2021-08-29 11:32:53 · 73 阅读 · 0 评论 -
PTA甲级 1133 Splitting A Linked List (C++)
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-29 10:52:54 · 81 阅读 · 0 评论