PAT-A
文章平均质量分 77
peanwang
这个作者很懒,什么都没留下…
展开
-
PAT 1106 Lowest Price in Supply Chain (25 分)
1106 Lowest Price in Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Startin...原创 2018-11-21 16:04:12 · 90 阅读 · 0 评论 -
PAT 1069 The Black Hole of Numbers (20 分)
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,...原创 2018-11-24 20:25:29 · 108 阅读 · 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 ...原创 2018-11-23 15:53:58 · 266 阅读 · 0 评论 -
PAT 1096 Consecutive Factors (20 分) 测试点
1096 Consecutive Factors (20 分)Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×5×6×7, where 5, 6, and 7 are the three...原创 2018-11-29 08:32:27 · 498 阅读 · 1 评论 -
PAT 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 happen...原创 2018-12-02 11:39:32 · 149 阅读 · 0 评论 -
PAT 1104 Sum of Number Segments (20 分)
1104 Sum of Number Segments (20 分)Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segmen...原创 2018-11-25 14:30:18 · 607 阅读 · 1 评论 -
PAT 1049 Counting Ones (30 分)
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 bein...原创 2018-11-25 16:23:40 · 175 阅读 · 0 评论 -
PAT 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 ...原创 2018-12-02 14:20:35 · 114 阅读 · 0 评论 -
PAT 1076 Forwards on Weibo (30 分)
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 wit...原创 2018-12-04 15:20:55 · 175 阅读 · 0 评论 -
PAT 1064 Complete Binary Search Tree (30 分)
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 ...原创 2018-11-24 16:07:38 · 135 阅读 · 0 评论 -
PAT 1099 Build A Binary Search Tree (30 分)
1099 Build A 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 l...原创 2018-11-24 15:55:24 · 179 阅读 · 0 评论 -
PAT 1053 Path of Equal Weight (30 分)
1053 Path of Equal Weight (30 分)Given a non-empty tree with root R, and with weight WiW_iWi assigned to each tree node TiT_iTi. The weight of a path from R to L is defined to be the sum of the weig...原创 2018-11-23 17:09:05 · 164 阅读 · 0 评论 -
PAT 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 ...原创 2018-11-17 11:18:05 · 141 阅读 · 0 评论 -
PAT 1086 Tree Traversals Again (25 分)
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 f...原创 2018-11-19 23:15:25 · 153 阅读 · 0 评论 -
PAT 1102 Invert a Binary Tree (25 分)
1102 Invert a Binary Tree (25 分)The following is from Max Howell @twitter:Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fu...原创 2018-11-19 23:16:48 · 159 阅读 · 0 评论 -
PAT 1097 Deduplication on a Linked List (25 分)
1097 Deduplication on a Linked List (25 分)Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, ...原创 2018-11-17 14:46:45 · 152 阅读 · 0 评论 -
PAT 1052 Linked List Sorting (25 分)
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...原创 2018-11-17 17:20:28 · 174 阅读 · 0 评论 -
PAT 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 l...原创 2018-11-24 15:04:29 · 133 阅读 · 0 评论 -
PAT 1088 Rational Arithmetic (20 分)
1088 Rational Arithmetic (20 分)For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient.Input Specification:Each...原创 2018-11-27 14:50:21 · 263 阅读 · 0 评论 -
PAT 1107 Social Clusters (30 分)
解析#include<cstdio>#include<vector>#include<algorithm>using namespace std;const int maxn = 1010;int hobby[maxn]{0};bool isroot[maxn]{ false };int findFather(int x) { if (x =...原创 2018-12-04 21:23:41 · 382 阅读 · 0 评论 -
PAT 1081 Rational Sum (20 分)
1081 Rational Sum (20 分)Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum.Input Specification:Each input file contains one test case. Each case st...原创 2018-11-27 15:15:50 · 113 阅读 · 0 评论 -
PAT 1062 Talent and Virtue (25 分)
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 outst...原创 2018-12-05 14:08:27 · 139 阅读 · 0 评论 -
PAT 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 retu...原创 2018-12-08 10:12:41 · 301 阅读 · 0 评论 -
PAT1072 Gas Station (30 分)
解析#include&lt;iostream&gt;#include&lt;string&gt;#include&lt;vector&gt;#include&lt;algorithm&gt;#include&lt;unordered_map&gt;using namespace std;const int INF = 0x3ffff原创 2018-12-08 12:41:53 · 261 阅读 · 0 评论 -
PAT 1087 All Roads Lead to Rome (30 分)
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 happ...原创 2018-12-08 14:14:20 · 281 阅读 · 0 评论 -
PAT 1021 Deepest Root (25 分)
1021 Deepest Root (25 分)A graph which is connected and acyclic can be considered a tree. The hight of the tree depends on the selected root. Now you are supposed to find the root that results in a hi...原创 2018-12-03 21:41:13 · 187 阅读 · 0 评论 -
PAT 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 ...原创 2018-12-04 09:43:36 · 207 阅读 · 0 评论 -
PAT test1 :1108,1109,1110,1111
模考马上要考PAT甲级了。所以后面的题目就当模考了。第一次模考成绩成绩用时792小时55分钟最后一道图题好复杂,而且我没学好图。所以最后一道题只拿了第一个测试点的9分。解析1108 Finding Average这是乙级的一道题。当时做的时候强行把实现了stod。当时记得花了很长时间。现在是模考,时间要紧,所以STL有stod,就用了STL的。其实只是判...原创 2018-12-06 17:27:06 · 291 阅读 · 0 评论 -
PAT 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 de...原创 2018-12-07 21:14:26 · 106 阅读 · 0 评论 -
PAT1003 Emergency (25 分)
解析#include&lt;cstdio&gt;#include&lt;vector&gt;#include&lt;algorithm&gt;using namespace std;const int maxn = 1000;const int INF = 0x3fffffff;struct Node{ int v, w; Node(int _v, int _w) :v(_...原创 2018-12-07 19:18:13 · 154 阅读 · 0 评论 -
PAT 1059 Prime Factors (25 分)
解析#include<cstdio>#include<cmath>#include<vector>using namespace std;vector<bool> prime;vector<int> PNum;struct factor { int x, cnt;}fac[10];void makePrime(in...原创 2018-11-30 17:11:34 · 92 阅读 · 0 评论 -
PAT 1078 Hashing (25 分)
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 t...原创 2018-11-28 16:08:59 · 126 阅读 · 0 评论 -
PAT 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 ...原创 2018-12-03 11:10:17 · 113 阅读 · 0 评论 -
PAT1084 Broken Keyboard (20 分)
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 stri...原创 2018-12-07 17:36:31 · 194 阅读 · 0 评论 -
PAT1092 To Buy or Not to Buy (20 分)
1092 To Buy or Not to Buy (20 分)Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the...原创 2018-12-07 17:39:10 · 274 阅读 · 0 评论 -
PAT1041 Be Unique (20 分)
1041 Be Unique (20 分)Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1,10410^4104]...原创 2018-12-07 17:45:25 · 114 阅读 · 0 评论 -
PAT1050 String Subtraction (20 分)
解析是集合A中的元素去掉集合B的元素。#include<iostream>#include<cstdio>#include<string>#include<vector>#include<algorithm>#include<set>using namespace std;int main(){ str...原创 2018-12-07 17:48:07 · 208 阅读 · 0 评论 -
PAT1048 Find Coins (25 分)
解析#include&amp;lt;iostream&amp;gt;#include&amp;lt;string&amp;gt;#include&amp;lt;vector&amp;gt;#include&amp;lt;algorithm&amp;gt;#include&amp;lt;unordered_set&amp;gt;usin原创 2018-12-07 19:00:00 · 175 阅读 · 0 评论 -
PAT 1146 Topological Order (25 分)
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 suppo...原创 2018-12-07 10:19:50 · 189 阅读 · 0 评论 -
PAT 1094 The Largest Generation (25 分)
1094 The Largest Generation (25 分)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 w...原创 2018-11-21 15:18:56 · 159 阅读 · 0 评论