![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT
灏辕
这个作者很懒,什么都没留下…
展开
-
PAT 甲级 1118(Birds in Forest)
PAT 甲级 1042题目要求翻译代码思路题目要求翻译一幅画里面的鸟为同一棵树上的,问有多少棵树和多少只鸟,以及对于两只鸟判断是否在同一个树上。代码#include<iostream>#include<vector>#include<cstring>#include<algorithm>#include<set>using namespace std;set<int> ids;int Rank[10010],p原创 2020-09-19 20:02:41 · 169 阅读 · 1 评论 -
PAT 甲级 1114(Family Property)
PAT 甲级 1042题目要求翻译代码思路题目要求翻译给定每个人的家庭成员和其自己名下的房产,请你统计出每个家庭的人口数、人均房产面积及房产套数。首先在第一行输出家庭个数(所有有亲属关系的人都属于同一个家庭)。随后按下列格式输出每个家庭的信息:家庭成员的最小编号 家庭人口数 人均房产套数 人均房产面积。其中人均值要求保留小数点后3位。家庭信息首先按人均面积降序输出,若有并列,则按成员编号的升序输出。代码#include<iostream>#include<algorithm&原创 2020-09-19 17:55:25 · 184 阅读 · 1 评论 -
PAT 甲级 1042(Be Unique)
PAT 甲级 1042题目要求翻译代码思路题目要求Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid “inside jobs” where employees collaborate with gamblers by performing inadequate sh原创 2020-09-17 19:25:29 · 204 阅读 · 0 评论 -
PAT 甲级 1041 (Be Unique)
PAT 甲级 1041题目要求翻译代码思路题目要求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 ]. The first one who bets on a unique number wins原创 2020-09-17 18:38:57 · 104 阅读 · 0 评论 -
PAT 甲级 1040 (Longest Symmetric String)
PAT 甲级 1039题目要求翻译代码思路题目要求Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given Is PAT&TAP symmetric?, the longest symmetric sub-string is s PAT&TAP s, hence you must output 11.Input Specifi原创 2020-09-17 18:27:12 · 107 阅读 · 0 评论 -
PAT 甲级 1039 (Course List for Student )
PAT 甲级 1039题目要求翻译代码思路题目要求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 registered course list for each student who comes for a query.Input Specificat原创 2020-09-17 15:03:50 · 89 阅读 · 0 评论 -
PAT 甲级 1038 (Recover the Smallest Number )
PAT 甲级 1037题目要求翻译代码思路题目要求Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229-87 or 0229-32-87-321-3214 wi原创 2020-09-17 15:01:20 · 106 阅读 · 0 评论 -
PAT 甲级 1037 (Magic Coupon )
PAT 甲级 1037题目要求翻译代码思路题目要求翻译给两个集合,分别从两个集合中取值相乘,找最大的和代码#include<iostream>#include<algorithm>using namespace std;int main(){ int n1,n2,i,j,sum=0; int a[100000],b[100000]; cin>>n1; for(i=0;i<n1;i++) cin>>a[i原创 2020-09-16 15:40:57 · 86 阅读 · 0 评论 -
PAT 甲级 1036 (Boys vs Girls)
PAT 甲级 1036题目要求翻译代码思路题目要求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 Specification:Each input file contains one test case. Each case contains a原创 2020-09-16 13:52:42 · 134 阅读 · 0 评论 -
PAT 甲级 1035 (Password)
PAT 甲级 1031题目要求翻译代码思路题目要求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 1 (one) from l (L in lowercase), or 0 (zero) fr原创 2020-09-16 11:52:38 · 129 阅读 · 0 评论 -
PAT 甲级 1032 (Sharing)
PAT 甲级 1032题目要求翻译代码思路题目要求翻译输出第一个共用的节点地址代码#include<iostream>using namespace std;struct NODE{ int next; char data; bool flag;};NODE node[100001];int main(){ int f1,f2,num; cin>>f1>>f2>>num; int ad,原创 2020-09-16 11:25:45 · 94 阅读 · 0 评论 -
PAT 甲级 1031 (Hello World for U)
PAT 甲级 1031题目要求翻译代码思路题目要求翻译将字符串打印成U型代码#include<iostream>#include<string.h>using namespace std;int main(){ char s[100]; scanf("%s",s); int len=strlen(s); int n1 = (len+2) / 3; int n2 = len +2 - 2*n1; int p=0,q=原创 2020-09-15 22:20:51 · 87 阅读 · 0 评论 -
PAT 甲级 1030 (Travel Plan)
PAT 甲级 1030题目要求翻译代码思路题目要求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原创 2020-09-15 19:23:24 · 146 阅读 · 0 评论 -
PAT 甲级 1029 (Median)
PAT 甲级 1029题目要求翻译代码思路题目要求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 sequen原创 2020-09-15 15:32:54 · 136 阅读 · 0 评论 -
PAT 甲级 1028 (List Sorting)
PAT 甲级 1028题目要求翻译代码思路题目要求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 (≤10510^5105) and C原创 2020-09-15 12:00:15 · 92 阅读 · 0 评论 -
PAT 甲级 1027 (Colors in Mars)
PAT 甲级 1027题目要求翻译代码思路题目要求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-09-15 11:09:50 · 86 阅读 · 0 评论 -
PAT 甲级 1025 (PAT Ranking)
PAT 甲级 1025题目要求翻译代码思路题目要求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 aft原创 2020-09-12 17:57:01 · 102 阅读 · 0 评论 -
PAT 甲级 1024 (Palindromic Number)
PAT 甲级 1024题目要求翻译代码思路题目要求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 can原创 2020-09-12 17:13:39 · 144 阅读 · 0 评论 -
PAT 甲级 1023(Have Fun with Numbers)
PAT 甲级 1023题目要求翻译代码思路题目要求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 numbers f原创 2020-09-12 11:15:06 · 174 阅读 · 0 评论 -
PAT 甲级 1022(Digital Library)
PAT 甲级 1022题目要求翻译代码思路题目要求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-09-11 23:46:26 · 184 阅读 · 0 评论 -
PAT 甲级 1021(Deepest Root )
PAT 甲级 1021题目要求翻译代码思路题目要求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.I原创 2020-09-11 22:35:19 · 253 阅读 · 0 评论 -
PAT 甲级 1020(Tree Traversals )
PAT 甲级 1020题目要求翻译代码思路题目要求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-09-11 15:41:00 · 87 阅读 · 0 评论 -
PAT 甲级 1019(General Palindromic Number)
PAT 甲级 1019题目要求翻译代码思路题目要求翻译判断转换进制后的数是不是回文代码#include<iostream>#include<vector>using namespace std;vector<int> v;bool transfor(int n,int b){ v.clear(); do{ v.push_back(n%b); n /=b; }while(n!=0);//“除基取余原创 2020-09-11 10:13:40 · 136 阅读 · 0 评论 -
PAT 甲级 1017(Queueing at Bank)
PAT 甲级 1017题目要求翻译代码思路题目要求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-09-10 19:26:08 · 90 阅读 · 0 评论 -
PAT 甲级 1018(Public Bike Management)
PAT 甲级 1016题目要求翻译代码题目要求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原创 2020-07-02 23:57:54 · 148 阅读 · 0 评论 -
PAT 甲级 1015(Reversible Primes)
PAT 甲级 1015题目要求翻译代码思路题目要求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 positi原创 2020-06-24 13:56:27 · 219 阅读 · 0 评论 -
PAT 乙级 1050(螺旋矩阵 )
PAT 乙级 1050题目要求代码思路题目要求本题要求将给定的 N 个正整数按非递增的顺序,填入“螺旋矩阵”。所谓“螺旋矩阵”,是指从左上角第 1 个格子开始,按顺时针螺旋方向填充。要求矩阵的规模为 m 行 n 列,满足条件:m×n 等于 N;m≥n;且 m−n 取所有可能值中的最小值。输入格式:输入在第 1 行中给出一个正整数 N,第 2 行给出 N 个待填充的正整数。所有数字不超过 10410^4104,相邻数字以空格分隔。输出格式:输出螺旋矩阵。每行 n 个数字,共 m 行。相邻数字以 1原创 2020-06-24 11:21:21 · 119 阅读 · 0 评论 -
PAT 乙级 1049(数列的片段和 )
PAT 乙级 1049题目要求代码思路题目要求给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列 { 0.1, 0.2, 0.3, 0.4 },我们有 (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4) (0.3) (0.3, 0.4) (0.4) 这 10 个片段。给定正整数数列,求出全部片段包含的所有的数之和。如本例中 10 个片段总和是 0.1 +原创 2020-05-15 10:33:40 · 257 阅读 · 0 评论 -
PAT 乙级 1048(数字加密)
PAT 乙级 1048题目要求代码思路题目要求本题要求实现一种数字加密方法。首先固定一个加密用正整数 A,对任一正整数 B,将其每 1 位数字与 A 的对应位置上的数字进行以下运算:对奇数位,对应位的数字相加后对 13 取余——这里用 J 代表 10、Q 代表 11、K 代表 12;对偶数位,用 B 的数字减去 A 的数字,若结果为负数,则再加 10。这里令个位为第 1 位。输入格式:输入在一行中依次给出 A 和 B,均为不超过 100 位的正整数,其间以空格分隔。输出格式:在一行中输出加密后的原创 2020-05-15 09:19:51 · 159 阅读 · 0 评论 -
PAT 甲级 1014(Waiting in Line)
PAT 甲级 1014题目要求翻译代码思路题目要求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-05-11 15:16:07 · 144 阅读 · 0 评论 -
PAT 乙级 1047(编程团体赛)
PAT 乙级 1047题目要求代码思路题目要求编程团体赛的规则为:每个参赛队由若干队员组成;所有队员独立比赛;参赛队的成绩为所有队员的成绩和;成绩最高的队获胜。现给定所有队员的比赛成绩,请你编写程序找出冠军队。输入格式:输入第一行给出一个正整数 N(≤104 ),即所有参赛队员总数。随后 N 行,每行给出一位队员的成绩,格式为:队伍编号-队员编号 成绩,其中队伍编号为 1 到 1000 的正整数,队员编号为 1 到 10 的正整数,成绩为 0 到 100 的整数。输出格式:在一行中输原创 2020-05-10 14:33:44 · 147 阅读 · 0 评论 -
PAT 乙级 1046(划拳)
PAT 乙级 1045题目要求代码思路题目要求划拳是古老中国酒文化的一个有趣的组成部分。酒桌上两人划拳的方法为:每人口中喊出一个数字,同时用手比划出一个数字。如果谁比划出的数字正好等于两人喊出的数字之和,谁就赢了,输家罚一杯酒。两人同赢或两人同输则继续下一轮,直到唯一的赢家出现。下面给出甲、乙两人的划拳记录,请你统计他们最后分别喝了多少杯酒。输入格式:输入第一行先给出一个正整数 N(≤100),随后 N 行,每行给出一轮划拳的记录,格式为:甲喊 甲划 乙喊 乙划其中喊是喊出的数字,划是划出的数原创 2020-05-10 14:01:34 · 479 阅读 · 0 评论 -
PAT 乙级 1045(快速排序)(有坑点:测试点2)
PAT 乙级 1045题目要求代码思路题目要求著名的快速排序算法里有一个经典的划分过程:我们通常采用某种方法取一个元素作为主元,通过交换,把比主元小的元素放到它的左边,比主元大的元素放到它的右边。 给定划分后的 N 个互不相同的正整数的排列,请问有多少个元素可能是划分前选取的主元?例如给定 N=5N = 5N=5, 排列是1、3、2、4、5。则:1 的左边没有元素,右边的元素都比它大,所以它可能是主元;尽管 3 的左边元素都比它小,但其右边的 2 比它小,所以它不能是主元;尽管 2 的右边元素都原创 2020-05-10 11:20:03 · 384 阅读 · 0 评论 -
PAT 乙级 1044( 火星数字)
PAT 乙级 1044题目要求代码思路题目要求火星人是以 13 进制计数的:地球人的 0 被火星人称为 tret。地球人数字 1 到 12 的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec。火星人将进位以后的 12 个高位数字分别称为:tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou。例如地球人的数字 29 翻译成火星文就是 hel mar;而火原创 2020-05-10 08:48:09 · 134 阅读 · 0 评论 -
PAT 甲级 1013(Battle Over Cities )
PAT 甲级 1013题目要求翻译代码思路题目要求翻译在战争中,所有的城市都通过高速公路连接在一起,这一点是至关重要的。如果一个城市被敌人占领了,那么所有连接这个城市的高速公路都会被封闭。我们必须马上知道为了使得余下的城市保持连接状态,我们是否需要修建其他的高速公路。给你一张城市地图,上面标识出了所有余下的高速公路,你需要快速说出需要修建的高速公路的数量。举个例子,如果我们有3座城市,2条高速公路分别连接city1-city2、city1-city3。如果city1被敌人占领了,我们就需要修建一条原创 2020-05-09 23:00:04 · 123 阅读 · 0 评论 -
PAT 甲级 1012(The Best Rank )
PAT 甲级 1012题目要求翻译代码思路题目要求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 en原创 2020-05-09 19:36:50 · 100 阅读 · 0 评论 -
PAT 乙级 1041( 考试座位号 )
PAT 乙级 1041题目要求代码思路题目要求每个 PAT 考生在参加考试时都会被分配两个座位号,一个是试机座位,一个是考试座位。正常情况下,考生在入场时先得到试机座位号码,入座进入试机状态后,系统会显示该考生的考试座位号码,考试时考生需要换到考试座位就座。但有些考生迟到了,试机已经结束,他们只能拿着领到的试机座位号码求助于你,从后台查出他们的考试座位号码。输入格式:输入第一行给出一个正整...原创 2020-05-02 22:25:39 · 153 阅读 · 0 评论 -
PAT 乙级 1038( 统计同成绩学生 )
PAT 乙级 1038题目要求代码思路题目要求本题要求读入 N 名学生的成绩,将获得某一给定分数的学生人数输出。输入格式:输入在第 1 行给出不超过 10510^5105 的正整数 N,即学生总人数。随后一行给出 N 名学生的百分制整数成绩,中间以空格分隔。最后一行给出要查询的分数个数 K(不超过 N 的正整数),随后是 K 个分数,中间以空格分隔。输出格式:在一行中按查询顺序给出得分...原创 2020-05-01 22:25:15 · 70 阅读 · 0 评论 -
PAT 乙级 1037( 在霍格沃茨找零钱 )
PAT 乙级 1037题目要求代码思路题目要求如果你是哈利·波特迷,你会知道魔法世界有它自己的货币系统 —— 就如海格告诉哈利的:“十七个银西可(Sickle)兑一个加隆(Galleon),二十九个纳特(Knut)兑一个西可,很容易。”现在,给定哈利应付的价钱 P 和他实付的钱 A,你的任务是写一个程序来计算他应该被找的零钱。输入格式:输入在 1 行中分别给出 P 和 A,格式为 Gall...原创 2020-04-30 22:44:44 · 174 阅读 · 1 评论 -
PAT 乙级 1036( 跟奥巴马一起编程 )
PAT 乙级 1036题目要求代码思路题目要求美国总统奥巴马不仅呼吁所有人都学习编程,甚至以身作则编写代码,成为美国历史上首位编写计算机代码的总统。2014 年底,为庆祝“计算机科学教育周”正式启动,奥巴马编写了很简单的计算机代码:在屏幕上画一个正方形。现在你也跟他一起画吧!输入格式:输入在一行中给出正方形边长 N(3≤N≤20)和组成正方形边的某种字符 C,间隔一个空格。输出格式:输...原创 2020-04-30 18:36:04 · 176 阅读 · 0 评论