
PAT 甲级
UKnowNothing_
一个机械专业的码农。
展开
-
2018.9.8 第一次参加 PAT 甲级代码
第一题,史上最坑的20分题目,提交3000多,通过率0.04;我过了两个测试点 8分,用时 1小时20分;# include <iostream># include <cstdio># include <vector># include <algorithm>using namespace std;const int maxn =...原创 2018-09-08 19:38:33 · 1012 阅读 · 4 评论 -
PAT 甲级 1079 Total Sales of Supply Chain(25 分)
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.Startin...原创 2018-08-24 19:20:49 · 408 阅读 · 0 评论 -
PAT 甲级 1066 Root of AVL Tree(25 分)
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 ...原创 2018-08-24 19:19:50 · 310 阅读 · 0 评论 -
PAT 乙级 1028 人口普查(20 分)
1028 人口普查(20 分)某城镇进行人口普查,得到了全体居民的生日。现请你写个程序,找出镇上最年长和最年轻的人。这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过 200 岁的老人,而今天是 2014 年 9 月 6 日,所以超过 200 岁的生日和未出生的生日都是不合理的,应该被过滤掉。输入格式:输入在第一行给出正整数 N,取值在(0,105];...原创 2018-08-23 19:24:38 · 216 阅读 · 0 评论 -
PAT 甲级 1101 Quick Sort(25 分)
1101 Quick Sort(25 分)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pi...原创 2018-08-23 19:22:51 · 251 阅读 · 0 评论 -
PAT 甲级 1098 Insertion or Heap Sort(25 分)
1098 Insertion or Heap Sort(25 分)According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort remov...原创 2018-08-23 19:22:10 · 234 阅读 · 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-08-23 19:21:21 · 280 阅读 · 0 评论 -
PAT 甲级 1063 Set Similarity(25 分)
1063 Set Similarity(25 分)Given two sets of integers, the similarity of the sets is defined to be Nc/Nt×100%, where Nc is the number of distinct common numbers shared by the two sets, and N...原创 2018-08-23 19:20:34 · 297 阅读 · 0 评论 -
PAT 甲级 1060 Are They Equal(25 分)
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 as 0.123×105 with simple chopping. Now...原创 2018-08-23 19:19:47 · 240 阅读 · 0 评论 -
PAT 甲级 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 pai...原创 2018-09-01 09:13:57 · 421 阅读 · 0 评论 -
PAT 甲级 1011 World Cup Betting(20 分)
1011 World Cup Betting(20 分)With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing battles for the World ...原创 2018-09-01 09:15:01 · 127 阅读 · 0 评论 -
PAT 甲级 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 whe...原创 2018-09-01 09:16:59 · 297 阅读 · 0 评论 -
PAT 甲级 1035 Password(20 分)
1035 Password(20 分)To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distingui...原创 2018-09-01 09:55:41 · 236 阅读 · 0 评论 -
PAT 甲级 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 ...原创 2018-09-01 09:54:27 · 318 阅读 · 0 评论 -
PAT 甲级 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 i...原创 2018-09-01 09:53:23 · 178 阅读 · 0 评论 -
PAT 甲级 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, ...原创 2018-09-01 09:51:37 · 231 阅读 · 0 评论 -
PAT 甲级 1028 List Sorting(25 分)
1028 List Sorting(25 分)Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, th...原创 2018-09-01 09:50:13 · 263 阅读 · 0 评论 -
PAT 甲级 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 ar...原创 2018-09-01 09:48:32 · 361 阅读 · 0 评论 -
PAT 甲级 1019 General Palindromic Number(20 分)
1019 General Palindromic Number(20 分)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 singl...原创 2018-09-01 09:46:54 · 277 阅读 · 0 评论 -
PAT 甲级 1059 Prime Factors(25 分)
1059 Prime Factors(25 分)Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1k1×p2k2×⋯×pmkm.Input Specific...原创 2018-08-23 19:18:59 · 295 阅读 · 0 评论 -
PAT 甲级 1009 Product of Polynomials (25)(25 分)
This time, you are supposed to find A*B where A and B are two polynomials.Input Specification:Each input file contains one test case. Each case occupies 2 lines, and each line contains the informa...原创 2018-08-23 19:17:54 · 146 阅读 · 0 评论 -
PAT 甲级 1052 Linked List Sorting (25)(25 分)
1052 Linked List Sorting (25)(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 po...原创 2018-08-22 16:55:59 · 200 阅读 · 0 评论 -
PAT 甲级 1047 Student List for Course(25 分)
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 nam...原创 2018-08-22 16:54:35 · 213 阅读 · 0 评论 -
PAT 甲级 1043 Is It a Binary Search Tree (25)(25 分)
1043 Is It a Binary Search Tree (25)(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 ...原创 2018-08-22 16:52:00 · 206 阅读 · 0 评论 -
PAT 甲级 1039 Course List for Student (25)(25 分)
1039 Course List for Student (25)(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 registere...原创 2018-08-22 16:51:08 · 156 阅读 · 0 评论 -
PAT 甲级 1034 Head of a Gang (30)(30 分)
1034 Head of a Gang (30)(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 ...原创 2018-08-22 16:50:26 · 244 阅读 · 0 评论 -
PAT 甲级 1030 Travel Plan (30)(30 分)
1030 Travel Plan (30)(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 ...原创 2018-08-22 16:48:55 · 192 阅读 · 0 评论 -
PAT 甲级 1025 PAT Ranking (25)(25 分)
1025 PAT Ranking (25)(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 severa...原创 2018-08-22 16:48:10 · 220 阅读 · 0 评论 -
PAT 甲级 1020 Tree Traversals (25)(25 分)
1020 Tree Traversals (25)(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 or...原创 2018-08-22 16:46:36 · 265 阅读 · 0 评论 -
PAT 甲级 1001 A+B Format (20)(20 分)
1001 A+B Format (20)(20 分)Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Inp...原创 2018-08-17 09:23:25 · 113 阅读 · 0 评论 -
PAT 甲级 1002 A+B for Polynomials (25)(25 分)
1002 A+B for Polynomials (25)(25 分)This time, you are supposed to find A+B where A and B are two polynomials.InputEach input file contains one test case. Each case occupies 2 lines, and each lin...原创 2018-08-17 09:24:35 · 157 阅读 · 0 评论 -
PAT 甲级 1003 Emergency (25)(25 分)
1003 Emergency (25)(25 分)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 t...原创 2018-08-17 09:27:04 · 210 阅读 · 0 评论 -
PAT 甲级 1007 Maximum Subsequence Sum (25)(25 分)
1007 Maximum Subsequence Sum (25)(25 分)Given a sequence of K integers { N~1~, N~2~, ..., N~K~ }. A continuous subsequence is defined to be { N~i~, N~i+1~, ..., N~j~ } where 1 <= i <= j <= K...原创 2018-08-23 19:17:15 · 226 阅读 · 0 评论 -
PAT 甲级 1004 Counting Leaves (30)(30 分)
1004 Counting Leaves (30)(30 分)A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.InputEach input file contains one test case...原创 2018-08-23 19:16:09 · 154 阅读 · 0 评论 -
PAT 甲级 1015 Reversible Primes (20)(20 分)
1015 Reversible Primes (20)(20 分)A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime ...原创 2018-08-17 09:34:21 · 161 阅读 · 0 评论 -
PAT 甲级 1013 Battle Over Cities (25)(25 分)
1013 Battle Over Cities (25)(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...原创 2018-08-17 09:33:30 · 144 阅读 · 0 评论 -
PAT 甲级 1012 The Best Rank (25)
1012 The Best Rank (25)(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 ...原创 2018-08-17 09:32:04 · 159 阅读 · 0 评论 -
PAT 甲级 1008 Elevator (20)(20 分)
1008 Elevator (20)(20 分)The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in speci...原创 2018-08-17 09:30:02 · 154 阅读 · 0 评论 -
PAT 甲级 1006 Sign In and Sign Out (25)(25 分)
1006 Sign In and Sign Out (25)(25 分)At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door. Given the ...原创 2018-08-17 09:29:18 · 291 阅读 · 0 评论 -
PAT 甲级 1005 Spell It Right (20)(20 分)
1005 Spell It Right (20)(20 分)Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input ...原创 2018-08-17 09:28:19 · 132 阅读 · 0 评论