
PAT 甲级
老虞面馆
这个作者很懒,什么都没留下…
展开
-
1008. Elevator (20)
Problem Description 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原创 2016-05-06 23:38:10 · 428 阅读 · 0 评论 -
1005. Spell It Right (20)
Problem Description 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 contai原创 2016-05-06 23:42:02 · 296 阅读 · 0 评论 -
1025. PAT Ranking (25) PAT 甲级
Problem Description 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原创 2016-07-19 00:16:23 · 711 阅读 · 0 评论 -
1002. A+B for Polynomials (25) PAT 甲级
Problem Description This time, you are supposed to find A+B where A and B are two polynomials.Input Each input file contains one test case. Each case occupies 2 lines, and each line contains the i原创 2016-08-17 15:21:46 · 298 阅读 · 0 评论 -
1046. Shortest Distance (20) PAT 甲级
Problem Description The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:原创 2016-08-17 15:24:47 · 283 阅读 · 0 评论 -
1065. A+B and C (64bit) (20) PAT 甲级
Problem Description Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C.Input Specification: The first line of the input gives the positive number of test case原创 2016-08-17 15:26:26 · 326 阅读 · 0 评论 -
1006. Sign In and Sign Out (25) PAT 甲级
传送门#include<stdio.h>struct P{ char id[20]; int hour,minute,second;}temp,ear,late;//tempbool cmp(struct P a,struct P b){ if(a.hour!=b.hour) return a.hour>=b.hour; if(a.minute!=b.minute原创 2016-08-21 17:36:45 · 375 阅读 · 0 评论 -
1011. World Cup Betting (20) PAT 甲级
传送门#include<iostream>#include<iomanip>using namespace std;char S[3]={'W','T','L'};int main(){ double num,temp; int max_index; double ans=1; for(int i=0;i<3;i++){ temp=0;原创 2016-08-21 17:38:16 · 365 阅读 · 0 评论 -
1036. Boys vs Girls (25) PAT 甲级
传送门#include<iostream>#include<math.h>using namespace std;struct Student{ char name[20]; char sex; char id[20]; int score;}boy,girl,temp;void init(){ boy.score=101; girl.score原创 2016-08-21 17:39:30 · 329 阅读 · 0 评论 -
1059. Prime Factors (25) PAT 甲级
Problem Description Given any positive integer N, you are supposed to find all of its prime factors, and write them in the format N = p1^k1 * p2^k2 *…*pm^km.Input Specification: Each input file co原创 2016-08-10 12:53:26 · 267 阅读 · 0 评论 -
1031. Hello World for U (20) PAT 甲级
传送门#include<stdio.h>#include<string.h>char str[90];char res[50][50];int main(){ int n,n1,n2; int l; for(int i=0;i<50;i++){ for(int j=0;j<50;j++){ res[i][j]=' ';原创 2016-08-22 14:29:39 · 415 阅读 · 0 评论 -
1042. Shuffling Machine (20) PAT 甲级
Problem Description 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 col原创 2016-08-11 13:39:30 · 334 阅读 · 0 评论 -
1020. Tree Traversals (25) PAT甲级
传送门#include<stdio.h>#include<queue>using namespace std;#define MAX_N 37int inorder[MAX_N],postorder[MAX_N];typedef struct Node{ int data; Node *lchild,*rchild;}node,*Btree;void create(Btree原创 2017-02-04 20:48:04 · 272 阅读 · 0 评论 -
1086. Tree Traversals Again (25) PAT甲级
传送门#include<stdio.h>#include<queue>#include<string.h>#include<stack>using namespace std;#define MAX_N 37int inorder[MAX_N],preorder[MAX_N];typedef struct Node{ int data; Node *lchild,*rchil原创 2017-02-04 21:25:21 · 254 阅读 · 0 评论 -
1102. Invert a Binary Tree (25) PAT甲级
传送门#include<stdio.h>#include<queue>#include<string.h>#include<stack>using namespace std;#define MAX_N 37int n;struct Node{ int lchild,rchild;}node[MAX_N];bool visited[MAX_N]={false};int strTonu原创 2017-02-04 22:14:22 · 277 阅读 · 0 评论 -
1032. Sharing (25) PAT甲级
传送门#include<stdio.h>#define MAX_N 1000100struct Node{ char data; int next; bool flag;}node[MAX_N];void init(){ for(int i=0;i<MAX_N;i++){ node[i].flag=false; }}int main(){原创 2017-02-07 14:14:09 · 1012 阅读 · 0 评论 -
1045.快速排序(25) PAT 乙级&&1101. Quick Sort (25)PAT甲级
著名的快速排序算法里有一个经典的划分过程:我们通常采用某种方法取一个元素作为主元,通过交换,把比主元小的元素放到它的左边,比主元大的元素放到它的右边。 给定划分后的N个互不相同的正整数的排列,请问有多少个元素可能是划分前选取的主元?例如给定N = 5, 排列是1、3、2、4、5。则:-1的左边没有元素,右边的元素都比它大,所以它可能是主元; -尽管3的左边元素都比它小,但是它右边的2它小,所以它不原创 2016-03-14 16:08:15 · 817 阅读 · 0 评论 -
1024. 科学计数法 (20)PAT乙级&&1073. Scientific Notation (20)PAT甲级
甲级传送门 乙级传送门#include<stdio.h>#include<string.h>#define MAX_N 10010char str[MAX_N];int main(){ gets(str); int l=strlen(str); if(str[0]=='-') printf("-"); int position=0; while(str[p原创 2017-02-07 23:33:06 · 729 阅读 · 0 评论 -
1034. 有理数四则运算(20)PAT乙级&&1088. Rational Arithmetic (20)PAT甲级
甲级传送门 乙级传送门#include<stdio.h>#include<math.h>#include <stdlib.h>#include<algorithm>//加上就通过 using namespace std;//加上就通过 typedef long long ll;ll gcd(ll a,ll b){ if(a%b==0) return b; e原创 2017-02-08 01:44:44 · 460 阅读 · 0 评论 -
1009. Product of Polynomials (25) PAT甲级
传送门#include<iostream>#include<iomanip>using namespace std;struct Poly{ int exp; double coe;}poly[1010];double ans[2020];int main(){ int m,n; int count=0; cin>>m; for(int i=0;原创 2017-01-17 14:42:01 · 252 阅读 · 0 评论 -
1019. General Palindromic Number (20) PAT 甲级
传送门坑点:边界数据0 2输出Yes 0 因此把进制转换部分改成do{ a[i]=m%n; m=m/n; i++;}while(m!=0);更优#include<iostream>using namespace std;int a[100];bool judge(int a[],int i){ for(int j=0;j<=i/2;j++原创 2017-01-17 15:15:13 · 269 阅读 · 0 评论 -
1027. Colors in Mars (20) PAT 甲级
传送门#include<cstdio>char radix[13]={'0','1','2','3','4','5','6','7','8','9','A' ,'B','C'};int main(){ int m,n,l; scanf("%d%d%d",&m,&n,&l); printf("#"); printf("%c%c",radi原创 2017-01-17 15:25:43 · 239 阅读 · 0 评论 -
1058. A+B in Hogwarts (20) PAT 甲级
传送门#include<cstdio>int main(){ int A[3],B[3],C[3]; int carry; scanf("%d.%d.%d",&A[0],&A[1],&A[2]); scanf("%d.%d.%d",&B[0],&B[1],&B[2]); C[2]=(A[2]+B[2])%29; carry=(A[2]+B[2])/2原创 2017-01-17 16:13:46 · 353 阅读 · 0 评论 -
1061. Dating (20)PAT甲级
传送门#include<iostream>#include<string>using namespace std;void day(int i){ string s[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"}; cout<<s[i-1]<<" ";}void hour(char c){ if(c<='9'&&c>='0'原创 2017-01-17 16:24:42 · 259 阅读 · 0 评论 -
1035. 插入与归并(25) PAT乙级&&1089. Insert or Merge (25)PAT甲级
甲级传送门乙级传送门#include<stdio.h>#include<algorithm>#define MAX_N 110using namespace std;int n;int aim[MAX_N];int ins[MAX_N];int merg[MAX_N];bool isSame(int a[],int b[]){ bool flag=true; for(int原创 2017-02-08 16:57:43 · 474 阅读 · 0 评论 -
1050. 螺旋矩阵(25) PAT乙级&&1105. Spiral Matrix (25)PAT甲级
传送门#include<stdio.h>#include<math.h>#include<algorithm>using namespace std;int N;int m,n;#define MAX_N 11000int a[MAX_N][MAX_N];int num[MAX_N];bool cmp(int a,int b){ return a>b;}void cal_m_n(原创 2017-02-08 21:39:03 · 455 阅读 · 0 评论 -
1049. 数列的片段和(20) PAT乙级 &1104. Sum of Number Segments (20)PAT甲级
问题描述 给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列{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个片段。 给定正整数数列,原创 2016-06-21 22:55:19 · 442 阅读 · 0 评论 -
1035. Password (20)PAT 甲级
传送门#include<iostream>#include<string>using namespace std;struct people{ string name; string passwd; bool ischange;}p[1010]; void replace(struct people &a,int &cnt){ for(int i=0;i<a.原创 2017-01-17 22:32:36 · 343 阅读 · 0 评论 -
1077. Kuchiguse (20) PAT甲级
传送门#include<iostream>#include<vector>using namespace std;vector<string> v;int main(){ int N; string s; int minLen=300; int count=0; cin>>N; //cin.sync();//清空缓冲区 getchar()原创 2017-01-18 09:57:32 · 310 阅读 · 0 评论 -
1025. 反转链表 (25)PAT乙级&&1074. Reversing Linked List (25)PAT甲级
甲级传送门 乙级传送门#include<stdio.h>#include<algorithm>using namespace std;#define MAX_N 100100struct Node{ int address; int next; int data; int order;}node[MAX_N];bool cmp(struct Node a,st原创 2017-02-09 19:35:30 · 521 阅读 · 0 评论 -
1028. List Sorting (25) PAT甲级
传送门#include<stdio.h>#include<algorithm>#include<string.h>#define MAX_N 100100using namespace std;struct Student{ int id; char name[15]; int grade;}stu[MAX_N];bool cmp1(struct Student a,原创 2017-02-09 23:15:51 · 278 阅读 · 0 评论 -
1016. Phone Bills (25) PAT甲级
传送门#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;#define MAX_N 1100struct Record{ char name[25]; int month,d,h,m; bool status;}r[MAX_N],temp;int toll[25];int原创 2017-02-18 20:25:05 · 283 阅读 · 0 评论 -
1015. 德才论 (25) PAT乙级&1062. Talent and Virtue (25)PAT甲级
甲级传送门 乙级传送门#include<stdio.h>#include<algorithm>#include<string.h> #include<iostream>using namespace std;struct stu{ char id[15]; int de,cai,sum; int flag;}Stu[100100];bool cmp(struct s原创 2017-01-19 18:43:35 · 339 阅读 · 0 评论 -
1003. Emergency (25) PAT 甲级
传送门#include<stdio.h>#include<string.h>#include<vector>using namespace std;#define MAX_V 510#define INF 1000000000int G[MAX_V][MAX_V];int weight[MAX_V];bool visited[MAX_V];int n,m;int num[MAX_V]原创 2017-02-28 19:22:28 · 376 阅读 · 0 评论 -
1030. Travel Plan (30) PAT 甲级
传送门#include<stdio.h>#include<vector>#include<algorithm>#include<string.h>using namespace std;#define MAX_V 510#define INF 100000000int n,m;int Start,End;int G[MAX_V][MAX_V];int d[MAX_V];int cos原创 2017-02-28 20:47:52 · 323 阅读 · 0 评论 -
1098. Insertion or Heap Sort (25) PAT甲级
传送门#include<stdio.h>#include<algorithm>#include<vector>#define MAX_N 110int ins[MAX_N],heap[MAX_N],aim[MAX_N];int n;void show(int a[]){ for(int i=1;i<=n;i++){ printf("%d",a[i]);原创 2017-02-10 17:19:45 · 481 阅读 · 0 评论 -
1107. Social Clusters (30) PAT甲级
传送门#include<stdio.h>#include<algorithm>using namespace std;#define MAX_N 1100int set[MAX_N];int n;int course[MAX_N];int root[MAX_N];int find(int x){ int r=x; while(set[r]!=r){ r=se原创 2017-02-10 18:42:06 · 291 阅读 · 0 评论 -
1099. Build A Binary Search Tree (30)PAT甲级
传送门#include<stdio.h>#include<queue>#include<algorithm>#define MAX_N 110using namespace std;struct Node{ int data; int lchild,rchild;}node[MAX_N];int n;int inorder[MAX_N];int co=0;void inO原创 2017-02-10 19:13:36 · 284 阅读 · 0 评论 -
1043. Is It a Binary Search Tree (25) PAT甲级
传送门#include<stdio.h>#include<vector>using namespace std;typedef struct Node{ int data; struct Node *lchild,*rchild; }BTnode,*BTree;int n;vector<int> ori,pre,preM,post,postM;void insert(BTre原创 2017-02-10 20:08:13 · 470 阅读 · 0 评论 -
1064. Complete Binary Search Tree (30) PAT甲级
传送门#include<stdio.h>#include<algorithm>using namespace std;#define MAX_N 1100int n;int CBSTree[MAX_N]; int in[MAX_N];int co=1;void inOrder(int root){ if(root>n) return; inOrder(root*2);原创 2017-02-10 20:21:45 · 294 阅读 · 0 评论