
PAT
PAT题解
liuxiaocs7
这个作者很懒,什么都没留下…
展开
-
PAT A1019 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 palindromic numbers are most often considered原创 2020-05-09 15:39:12 · 301 阅读 · 0 评论 -
7-3 垃圾分类 (20分)
据香港《南华早报》2019年7月15日文章,上海严格的垃圾分类新规令不少居民抓狂。这催生出大量帮助找出正确分类答案的App和小程序。目前仅微信上就至少有280种与垃圾处理有关的App,在苹果应用商店也达130种。支付宝表示,已有60多家独立App开发商申请为该平台提供类似服务。本题就请你现场实现一个简单的垃圾分类小助手。输入格式:输入首先给出官方分类指南中每种物品的归属。在一行中给出一个正整...原创 2020-05-01 20:09:43 · 3015 阅读 · 7 评论 -
7-2 三阶幸福数 (20分)
对一个十进制数的各位数字做一次立方和,称作一次迭代。如果一个十进制数能通过 h 次迭代得到 1,就称该数为三阶幸福数,迭代的次数 h 称为幸福度。例如 1579 经过 1 次迭代得到 1198,2 次迭代后得到 1243,3 次迭代后得到 100,最后得到 1。则 1579 是幸福数,其幸福度为 4。另一方面,如果一个大于1的数字经过数次迭代后进入了死循环,那这个数就不幸福。例如 97 迭代得到...原创 2020-05-01 20:09:05 · 1346 阅读 · 5 评论 -
7-1 Knuth洗牌法 (20分)
Knuth 洗牌法是生成 { 1, 2, …, n } 的一个随机重排列的算法。与每次反复随机生成一个数字,直到获得一个不重复的新数字的算法不同,Knuth 洗牌法从原始序列 { 1, 2, …, n } 开始,逐次洗牌。洗牌的方法是从左到右,每轮从没确定的数字中随机抽取一个数,把它放到确定的位置上。例如令 n 等于 4。我们从 { 1, 2, 3, 4 } 开始。记 i 到 N 之间的随机抽牌...原创 2020-05-01 20:08:27 · 536 阅读 · 0 评论 -
PAT A1020 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 cor...原创 2020-04-28 22:57:57 · 366 阅读 · 0 评论 -
PAT A1025 PAT Ranking(25)[PAT排名,排序]
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 w...原创 2020-04-13 00:48:33 · 139 阅读 · 0 评论 -
PAT A1022 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...原创 2020-04-12 19:54:22 · 233 阅读 · 0 评论 -
PAT A1012 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 - Eng...原创 2020-04-12 19:15:02 · 277 阅读 · 0 评论 -
PAT A1050 String Subtraction(20)[字符串减法,字符串]
Given two strings S1S_1S1 and S2S_2S2 S=S1−S2S=S_1-S_2S=S1−S2 is defined to be the remaining string after taking all the characters in S2S_2S2 from S1S_1S1. Your task is simply to calculate S1...原创 2020-04-12 02:05:31 · 203 阅读 · 0 评论 -
PAT A1036 Boys vs Girls(25)[男孩和女孩,字符串]
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input SpecificationEach input file contains one tes...原创 2020-04-12 02:03:47 · 398 阅读 · 0 评论 -
PAT A1035 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 distinguish...原创 2020-04-12 02:02:24 · 217 阅读 · 0 评论 -
PAT A1005 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 SpecificationEach input file contains one test case. Each ...原创 2020-04-12 01:57:53 · 163 阅读 · 0 评论 -
PAT A1001 A+B Format (20)[A+B格式,字符串]
Calculate a+ba+ba+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).Input SpecificationEach inpu...原创 2020-04-12 01:56:39 · 272 阅读 · 0 评论 -
PAT A1100 Mars Numbers(20)[火星数字,进制]
People on Mars count their numbers with base 13:Zero on Earth is called “tret” on Mars.The numbers 1 to 12 on Earth is called “jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec” on Mars, r...原创 2020-04-12 01:52:58 · 166 阅读 · 0 评论 -
PAT A1015 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 pr...原创 2020-04-12 01:51:01 · 124 阅读 · 0 评论 -
PAT A1027 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 dig...原创 2020-04-12 01:08:08 · 180 阅读 · 0 评论 -
PAT A1010 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 pair of positive integ...原创 2020-04-11 23:33:47 · 168 阅读 · 0 评论 -
PAT A1024 Palindromic Number(25)[回文数,高精度]
PAT A1024 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 digi...原创 2020-04-11 16:39:09 · 172 阅读 · 0 评论 -
PAT A1023 Have Fun with Numbers(20)[趣味数字,高精度]
PAT A1023 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 happ...原创 2020-04-11 15:58:04 · 151 阅读 · 0 评论 -
PAT A1009 roduct of Polynomials(25)[多项式相乘, 高精度]
PAT A1009 roduct 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, ...原创 2020-04-11 15:39:01 · 171 阅读 · 0 评论 -
PAT A1002 A+B for Polynomials(25)[多项式A+B, 高精度]
PAT A1002 A+B for Polynomials(25)This time, you are supposed to find A+B where A and B are two polynomials.Input SpecificationEach input file contains one test case. Each case occupies 2 lines, and...原创 2020-04-11 15:25:34 · 169 阅读 · 0 评论 -
PAT A1006 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 ...原创 2020-04-11 14:33:20 · 215 阅读 · 0 评论