![](https://img-blog.csdnimg.cn/20190918135101160.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
PAT
乙级、甲级
Q_smile
这个作者很懒,什么都没留下…
展开
-
PAT甲级1141 PAT Ranking of Institutions(25 分)
After each PAT, the PAT Center will announce the ranking of institutions based on their students' performances. Now you are asked to generate the ranklist.Input Specification:Each input file conta...原创 2018-08-15 16:58:55 · 185 阅读 · 0 评论 -
PAT甲级1145 Hashing - Average Search Time(25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer keys from the table and output the average sea...原创 2018-08-13 19:13:31 · 230 阅读 · 0 评论 -
PAT甲级1014 Waiting in Line (30)(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...原创 2018-08-19 10:19:16 · 196 阅读 · 0 评论 -
PAT甲级1147 Heaps(30 分)
In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...原创 2018-08-10 17:19:45 · 180 阅读 · 0 评论 -
PAT甲级 1039 Course List for Student(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 registered course list for each student who comes ...原创 2018-09-01 10:31:05 · 192 阅读 · 0 评论 -
PAT甲级 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 name lists of all the courses.Input S...原创 2018-09-01 10:47:42 · 171 阅读 · 0 评论 -
PAT甲级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 order traversal sequence of the cor...原创 2018-08-13 13:57:36 · 264 阅读 · 0 评论 -
PAT 甲级 1140 Look-and-say Sequence(20 分)
题目链接#include <iostream>#include <algorithm>#include <bits/stdc++.h>using namespace std;int main(){ int D; int n; while(~scanf("%d %d", &D, &n)) { ...原创 2018-07-09 15:39:08 · 335 阅读 · 0 评论 -
PAT甲级1142 Maximal Clique(25 分)
A clique is a subset of vertices of an undirected graph such that every two distinct vertices in the clique are adjacent. A maximal clique is a clique that cannot be extended by including one more adj...原创 2018-08-13 18:14:51 · 187 阅读 · 0 评论 -
PAT甲级1132 Cut Integer(20 分)
题目链接注意:除数为0的情况。#include <iostream>#include <algorithm>#include <bits/stdc++.h>using namespace std;long long a,b,c,d;int main(){ int n; scanf("%d", &n); for(int...原创 2018-07-09 19:40:11 · 233 阅读 · 0 评论 -
PAT甲级1143 Lowest Common Ancestor(30 分)
The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants.A binary search tree (BST) is recursively defined as a binary tree which has ...原创 2018-08-12 21:48:34 · 286 阅读 · 0 评论 -
PAT甲级 1144 The Missing Number(20 分)
题目链接#include <iostream>#include <bits/stdc++.h>#include <algorithm>using namespace std;int main(){ int n; while(~scanf("%d",&n)) { int arr[100000+1]; ...原创 2018-07-09 15:40:59 · 206 阅读 · 0 评论 -
PAT甲级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 supposed to write a program to test...原创 2018-08-06 17:54:48 · 278 阅读 · 0 评论 -
PAT甲级1136 A Delayed Palindrome(20 分)
题目链接注意:1、PAT提交不能用gets()函数。2、如果数字本身就是一个Palindrome number直接输出。#include <iostream>#include <algorithm>#include <bits/stdc++.h>using namespace std;bool isPalNum(char C[]){//判断是否是一...原创 2018-07-09 19:09:43 · 296 阅读 · 0 评论 -
PAT甲级1128 N Queens Puzzle(20 分)
题目链接#include <iostream>#include <algorithm>#include <bits/stdc++.h>using namespace std;int c[3][2048];//数组开到1024段错误......int main(){ int m; scanf("%d",&m); ...原创 2018-07-10 14:36:06 · 250 阅读 · 0 评论 -
1016 部分A+B (15分)
Github代码(不全,更新中)分析:水题#include <iostream>using namespace std;long long getP(string A, char DA){ int len = A.length(); int P = 0; int temp = DA-'0'; for(int i=0; i<len;...原创 2020-02-03 11:16:18 · 117 阅读 · 0 评论 -
1015 德才论 (25分)
Github代码(不全,更新中)分析:1.分类:德>=H,才>=H(第一类) 德>=H,才>=L(第二类) 德>=L,才>=L,德>=才(第三类) 德>=L,才>=L(第四类) 其他不满足条件者(第五类)2.排序:第一类>第二类>第三类>第四类>第五类;其次,类内排序按题目给的“总分相同时,按其德分...原创 2020-02-03 11:04:02 · 174 阅读 · 0 评论 -
1014 福尔摩斯的约会 (20分)
Github代码(不全,更新中)分析:【第一对相同的大写英文字母,包括A-G】,【第二对相同的字符,包括0-9,A-N】,【第三对相同的英文字母,包括大小写】,只要不踩坑,题目还是挺容易的......PS:限定字符的范围时,千万千万不要忘记写等号!!!比如ch<='a',不要写出ch<'a'!!!#include <iostream>#include <...原创 2020-02-03 09:38:32 · 180 阅读 · 0 评论 -
1013 数素数 (20分)
Github代码(不全,更新中)分析:老生常谈的素数题。1.数组开够2.按指定格式输出#include <iostream>#include <cstdio>#include <cmath>using namespace std;int prime[10001];int ind = 0;void getPrime(int N)...原创 2020-02-02 13:27:19 · 292 阅读 · 0 评论 -
1012 数字分类 (20分)
Github代码(不全,更新中)分析:按题目给的条件,一步步来就好,不难,要仔细#include <iostream>#include <cstdio>using namespace std;int main(){ int N, num; int A1 = 0, A2 = 0, A3 = 0, A5 = 0; double A4 ...原创 2020-02-02 12:21:20 · 352 阅读 · 0 评论 -
1010 一元多项式求导 (25分)
Github代码(不全,更新中)分析:求导过程不再赘述。要注意的是,如果全部都是零多项式,最后要输出"0 0"#include <iostream>#include <cstdio>using namespace std;typedef struct Part{ int _ratio; int _index; void deriva...原创 2020-02-02 11:37:29 · 220 阅读 · 0 评论 -
1009 说反话 (20分)
Github代码(不全,更新中)分析:逆置部分同1008,另外读入时注意结束标志#include <iostream>#include <cstdio>using namespace std;void inverse(string arr[], int head, int tail){ for(int i=head, j=tail-1; i<j...原创 2020-02-02 11:31:41 · 217 阅读 · 0 评论 -
1008 数组元素循环右移问题 (20分)
Github代码(不全,更新中)分析:将数组进行三次逆置操作,即可得到原地右移数组PS:基础的数据结构题,练习时建议不要取巧直接输出。#include <iostream>#include <algorithm>using namespace std;int inverse(int arr[], int head, int tail){//数组逆置 ...原创 2020-02-02 11:28:16 · 500 阅读 · 0 评论 -
1007 素数对猜想 (20分)
Github代码(不全,更新中)分析:先将1到N之间的素数找出来,然后便利查找素数对PS:如何判定素数?对于正整数n,若比n的小的素数均不能被n整除,则n是素数。{ int n; cin>>n; int prime[n+10]; int ind=0; //找出1到N之间的素数 prime[ind++] = 2; fo...原创 2020-02-02 11:23:41 · 195 阅读 · 1 评论 -
1006 换个格式输出整数 (15分)
Github代码(不全,更新中)分析:水题#include <iostream>#include <algorithm>using namespace std;int main(){ int num, ind=0; cin>>num; int a = num/100; while(a--){ ...原创 2020-02-02 10:14:14 · 197 阅读 · 0 评论 -
1005 继续(3n+1)猜想 (25分)
Github代码(不全,更新中)分析:定义标记数组,初始化为false,给定数据标记为true。验证过程中设计数据全部标记为false,最后标记为true的数据为最后答案。#include <iostream>#include <algorithm>using namespace std;bool flag[1024];int num[512];i...原创 2020-02-02 10:12:38 · 382 阅读 · 0 评论 -
1004 成绩排名 (20分)
Github代码(不全,更新中)分析:一边读入数据,一边比较即可,不难#include <iostream>#include <string>using namespace std;typedef struct Student{ string name; string id; int grade; Student(){};//...原创 2020-02-02 09:56:40 · 1044 阅读 · 0 评论 -
1003 我要通过! (20分)
Github代码(不全,更新中)分析:1.首先保证P前,T后,P和T之间全都是A2.根据题目的第二条和第三条:假如x="AA",则AAPATAA正确-->AAPAATAAAA正确-->AAPAAATAAAAAA正确-->... 2个|1个|2个 2个|2个|2*2个 2个| 3个 | 2*3个 ...原创 2020-02-02 09:52:41 · 255 阅读 · 0 评论 -
1011 A+B 和 C (15分)
Github代码(不全,更新中)分析:水题,定义long long类型读入数据处理即可#include <iostream>using namespace std;int main(){ int n; long long a, b, c; cin>>n; for(int i=1; i<=n; i++){ ...原创 2020-02-01 12:03:09 · 231 阅读 · 0 评论 -
1002 写出这个数 (20分)
GitHub代码(不全,更新中)分析:小心,不要将拼音打错#include <iostream>#include <string>using namespace std;string pinyin[] ={"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"};int main(...原创 2020-02-01 10:27:17 · 103 阅读 · 0 评论 -
1001 害死人不偿命的(3n+1)猜想 (15分)
GitHub代码(不全,更新中)分析:水题,不解释Source Code:#include <iostream>using namespace std;int main(){ int n; int time = 0; cin>>n; while(n != 1) { if(n % 2 == 0)...原创 2020-02-01 10:22:47 · 219 阅读 · 0 评论