PAT真题
PAT真题心得与解答
best小小周
这个作者很懒,什么都没留下…
展开
-
1088 Rational Arithmetic (20分) 最大公约数 字符串处理 纯C++
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 input file contains one test case, which gives in one lin原创 2020-07-22 21:13:52 · 108 阅读 · 0 评论 -
1090 Highest Price in Supply Chain (25分) 零售商分级
1090 Highest 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.Starting from one root supplier, everyone on the chain buys pro原创 2020-07-22 21:09:44 · 173 阅读 · 1 评论 -
1089 Insert or Merge (25分)归并排序还是插入排序
1089 Insert or Merge (25分)According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data, finds the location it belongs原创 2020-07-22 21:01:45 · 119 阅读 · 0 评论 -
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 suffix. For example, loading and being are stored as show原创 2020-07-18 17:44:26 · 122 阅读 · 0 评论 -
1031 Hello World for U (20分) 测试点5错误的坑
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 is, the characters must be printed in the original order, star原创 2020-07-17 17:40:19 · 386 阅读 · 0 评论 -
1030 Travel Plan (30分) 找最短路径 DFS
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 decide the shortest path between his/her starting city and原创 2020-07-17 16:59:07 · 123 阅读 · 0 评论 -
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, 10, 15, 16, 17 } is 15. The median of two sequences is de原创 2020-07-17 16:31:19 · 140 阅读 · 0 评论 -
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, the first line contains two integers N (≤105) and C, whe原创 2020-07-17 16:20:46 · 86 阅读 · 0 评论 -
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 are for Red, the middle 2 digits for Green, and the last 2原创 2020-07-17 16:04:52 · 75 阅读 · 0 评论 -
1026 Table Tennis (30分) 桌球排队带VIP的
1026 Table Tennis (30分)A table tennis club has N tables available to the public. The tables are numbered from 1 to N. For any pair of players, if there are some tables open when they arrive, they will be assigned to the available table with the smallest n原创 2020-07-17 15:42:22 · 178 阅读 · 0 评论 -
1025 PAT Ranking (25分) PAT排名排序
1025 PAT Ranking (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 several places, and the ranklists will be merged immediately after t原创 2020-07-17 08:30:25 · 198 阅读 · 1 评论 -
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 numbers are palindromic numbers.Non-palindromic numbers原创 2020-07-17 07:12:53 · 105 阅读 · 0 评论 -
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 happens to be another 9-digit number consisting exactly the num原创 2020-07-16 23:30:07 · 85 阅读 · 0 评论 -
1022 Digital Library (30分) 字符串处理
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 as its ID. Given any query fro原创 2020-07-16 22:27:36 · 116 阅读 · 0 评论 -
1021 Deepest Root (25分)最深树选根节点DFS
1021 Deepest Root (25分)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.Inpu原创 2020-07-16 21:25:26 · 148 阅读 · 0 评论 -
1020 Tree Traversals (25分)二叉树的遍历以及层次输出
1020 Tree Traversals (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 order traversal sequence of the corresponding binary tree.Input原创 2020-07-15 16:34:07 · 103 阅读 · 0 评论 -
1019 General Palindromic Number (20分) 回文数字符串翻转 测试2和4有点坑
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 single digit numbers are palindromic numbers.Although palindr原创 2020-07-15 10:22:44 · 121 阅读 · 0 评论 -
1017 Queueing at Bank (25分)银行排队
1017 Queueing at Bank (25分)Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. All the customers have to wait in line behind the yellow line, until it is his/her turn原创 2020-07-14 10:22:40 · 201 阅读 · 0 评论 -
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 when the call is made. When a customer starts connecting a lo原创 2020-07-14 08:53:29 · 207 阅读 · 0 评论 -
1015 Reversible Primes (20分) 素数转换
1015 Reversible Primes (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 because its reverse 37 is also a prime.Now given any two posi原创 2020-07-13 19:17:47 · 138 阅读 · 0 评论 -
1014 Waiting in Line (30分) 队列,银行排队
1014 Waiting in Line (30分)Suppose a bank has N windows 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 inside the yellow line in fro原创 2020-07-13 17:51:04 · 265 阅读 · 1 评论 -
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 must know immediately if we need to repair any other high原创 2020-07-12 15:32:23 · 210 阅读 · 0 评论 -
1012 The Best Rank (25分) 使用sort排序实现排名
1012 The Best Rank (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 or Linear Algrbra), and E - English. At the mean time, we enco原创 2020-07-12 09:01:30 · 211 阅读 · 0 评论 -
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 Cup trophy in South Africa. Similarly, football betting f原创 2020-07-11 21:01:40 · 125 阅读 · 0 评论 -
1009 Product of Polynomials (25分) 多项式乘法
1009 Product of Polynomials (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 information of a polynomial:K N原创 2020-07-11 18:47:30 · 126 阅读 · 0 评论 -
1008 Elevator (20分)电梯
1008 Elevator (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 specified order. It costs 6 seconds to move the elevator up one flo原创 2020-07-11 16:36:46 · 100 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25分)
1007 Maximum Subsequence Sum (25分)Given a sequence of K integers { N1, N2, …, NK}. A continuous subsequence is defined to be { Ni, Ni+1, …, Nj} where 1≤i≤j≤K. The Maximum Subsequence is the continuous subsequence which has the largest sum o原创 2020-07-11 15:24:09 · 79 阅读 · 0 评论 -
1006 Sign In and Sign Out (25分) 简单通俗解法
1006 Sign In and Sign Out (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 records of signing in’s and out’s, you are supposed to find th原创 2020-07-11 10:26:34 · 674 阅读 · 0 评论 -
1005 Spell It Right (20分) 简单解法
1005 Spell It Right (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 file contains one test case. Each case occupies one line which c原创 2020-07-11 08:41:52 · 290 阅读 · 0 评论 -
1003 Emergency (25分) DFS 深度优先遍历
1003 Emergency (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 teams in each city and the length of each road between any pair原创 2020-07-10 21:15:24 · 230 阅读 · 0 评论 -
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 test case. Each case starts with a line containing 0<N&原创 2020-07-11 05:45:03 · 115 阅读 · 0 评论