03 2015 档案
PAT:1022. Digital Library (30) (部分正确,错最后两个)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 int n; //n本书 9 //标题、作者、关键字、出版社、出版年份与ID的映射10 map> mp... 阅读全文
posted @ 2015-03-11 23:15 Evence 阅读(237) 评论(0) 推荐(0)
PAT:1023. Have Fun with Numbers (20) AC
摘要:#include#includechar str[30]; //输入的数字int tmp[30]; //*2后逆序的数字int cntstr[10]; //输入数字0-9的个数int tmpI=0,jin=0; //... 阅读全文
posted @ 2015-03-11 16:21 Evence 阅读(160) 评论(0) 推荐(0)
PAT:1081. Rational Sum (20) AC(类似math.h中的sqrt(1.0*n),algorithm的abs()用于取绝对值)
摘要:#include#includeusing namespace std;typedef long long ll; //【skill】重命名struct num{ ll zi,mu; //分子分母};ll gcd(ll a,ll b) //求最大公约数{ return ... 阅读全文
posted @ 2015-03-11 15:07 Evence 阅读(246) 评论(0) 推荐(0)
PAT:1013. Battle Over Cities (25) AC
摘要:#include#include#includeusing namespace std;const int MAX=1010;int n,m,k; //城市数,高速公路数,查询次数int DELETE; //要删除的点vector ADJ[MAX]; //邻... 阅读全文
posted @ 2015-03-11 09:44 Evence 阅读(115) 评论(0) 推荐(0)
PAT:1071. Speech Patterns (25) AC
摘要:#include#include#include#includeusing namespace std;bool check(char a) //判断是否为有效字符{ if(isdigit(a) || isalpha(a)) return true; return fal... 阅读全文
posted @ 2015-03-10 23:33 Evence 阅读(189) 评论(0) 推荐(0)
PAT:1054. The Dominant Color (20) AC(map法)
摘要:#include#includeusing namespace std;const int MAX=0x3fffffff;int main(){ int m,n; map count; //数字与出现次数的map映射 scanf("%d%d",&m,&n); for(int i... 阅读全文
posted @ 2015-03-10 22:47 Evence 阅读(134) 评论(0) 推荐(0)
PAT:1054. The Dominant Color (20) AC(抓住最多的特点,处理不同和相同的情况,留下剩余的答案)
摘要:#includeint main(){ int m,n,ans,tmp,times=0; scanf("%d%d",&m,&n); for(int i=0 ; i<n ; ++i) //【思维】题目找出现次数最多的一个,找到不同的,次数减少1,减少到0就换成输入的数字。找到相同的数字,次... 阅读全文
posted @ 2015-03-10 22:24 Evence 阅读(203) 评论(0) 推荐(0)
PAT:1060. Are They Equal (25) AC
摘要:#include#include#include#includeusing namespace std;int n;string deal(string s,int &e) //【思维】1:吸收多余0:。2:找到“.”判断与1的大小。3:去除“.”的同时统计10的指数(正负与st... 阅读全文
posted @ 2015-03-10 21:58 Evence 阅读(186) 评论(0) 推荐(0)
PAT:1047. Student List for Course (25) AC
摘要:#include#include#include#includeusing namespace std;const int MAX=40010;int n,k; //n个人,k门课char name[MAX][5]; //存n个人的名字vector course[MAX]... 阅读全文
posted @ 2015-03-10 18:34 Evence 阅读(139) 评论(0) 推荐(0)
PAT:1039. Course List for Student (25) 部分正确(最后一个大数据错误)
摘要:#include#include#include#includeusing namespace std;const int MAX=40010;const int H=26*26*26*10+10;int n,k; //n个人,k门课vector HAR[H];int getID(... 阅读全文
posted @ 2015-03-10 18:04 Evence 阅读(241) 评论(0) 推荐(0)
PAT:1004. Counting Leaves (30) AC
摘要:#include#includeconst int MAX=510;using namespace std;int n,m,le=0; //节点数,非叶子节点数,最深层叶层数vector child[MAX]; //存储孩子情况int number[MAX]; //... 阅读全文
posted @ 2015-03-10 16:29 Evence 阅读(120) 评论(0) 推荐(0)
PAT:1070. Mooncake (25) AC
摘要:#include#include#includeusing namespace std;struct moomcake{ double store; //【cation】这个可能是小数! double sumPrice; double solePrice;}M[1010];bool ... 阅读全文
posted @ 2015-03-10 13:01 Evence 阅读(154) 评论(0) 推荐(0)
PAT:1061. Dating (20) AC
摘要:#include#include#include#includeusing namespace std;char alp[7][5]={"MON","TUE","WED","THU","FRI","SAT","SUN"};int main(){ /*char test='E'; printf("... 阅读全文
posted @ 2015-03-10 11:48 Evence 阅读(179) 评论(0) 推荐(0)
PAT:1003. Emergency (25) AC
摘要:#include#include#includeusing namespace std;const int MAXV=510;const int INF=0x3fffffff;int n,m,c1,c2;bool vis[MAXV];int G[MAXV][MAXV]; //城市间距离in... 阅读全文
posted @ 2015-03-09 22:46 Evence 阅读(121) 评论(0) 推荐(0)
PAT:1030. Travel Plan (30) AC
摘要:#include#include#includeusing namespace std;const int MAXV=510;const int INF=0x3fffffff;int N,M,S,D; //城市数,高速公路数,起点,终点bool visit[MAXV]; //标记... 阅读全文
posted @ 2015-03-09 18:51 Evence 阅读(189) 评论(0) 推荐(0)
PAT:1064. Complete Binary Search Tree (30) AC
摘要:#include#includeusing namespace std;const int MAX=1010;int n;int arr[MAX]; //存放原始数组int arrI=0;int CBT[MAX]; //二叉排序树层序遍历序列【思维】中序遍历在数组中存放的就是层序... 阅读全文
posted @ 2015-03-08 17:04 Evence 阅读(147) 评论(0) 推荐(0)
PAT:1053. Path of Equal Weight (30) AC
摘要:#include#include#include#includeusing namespace std;const int MAX=1010;int n,m; //n个节点,m个非叶子节点 long long int S; //待测权值long long int weight[M... 阅读全文
posted @ 2015-03-08 16:31 Evence 阅读(111) 评论(0) 推荐(0)
PAT:1079. Total Sales of Supply Chain (25) AC
摘要:#include#include#includeusing namespace std;const int MAX=100010;int DEPest=0;int root=-1,N;double P,r,sum=0;vector child[MAX]; //child[父亲][孩子]... 阅读全文
posted @ 2015-03-08 14:37 Evence 阅读(118) 评论(0) 推荐(0)
PAT:1090. Highest Price in Supply Chain (25) AC
摘要:#include#includeusing namespace std;const int MAX=100010;int DEPest=0,times=0;vector child[MAX]; //child[父亲][孩子] 二维数组表示树形结构void DFS(int root,i... 阅读全文
posted @ 2015-03-08 13:59 Evence 阅读(220) 评论(0) 推荐(0)
PAT:1003. 我要通过!(20) AC
摘要:#include#includeint main(){ int n; scanf("%d",&n); while(n--) { char str[110]; scanf("%s",str); int len=strlen(str); int numP=0,numT=0... 阅读全文
posted @ 2015-03-08 11:25 Evence 阅读(184) 评论(0) 推荐(0)
PAT:1027. 打印沙漏(20) AC
摘要:#includeint main(){ int n; char xing; scanf("%d %c",&n,&xing); int num=1,i=1; while(1) { num = num + 2 * (i + 2); //一开始就超出,不改变i if... 阅读全文
posted @ 2015-03-07 18:39 Evence 阅读(150) 评论(0) 推荐(0)
PAT:1027. 打印沙漏(20) AC
摘要:#includeint main(){ int n; char xing; scanf("%d %c",&n,&xing); int num=1,i=1; while(1) { num = num + 2 * (i + 2); //一开始就超出,不改变i if... 阅读全文
posted @ 2015-03-07 18:39 Evence 阅读(90) 评论(0) 推荐(0)
PAT:1014. 福尔摩斯的约会 (20) AC
摘要:#include#include#include#include#includeusing namespace std;char g1[99],g2[99],g3[99],g4[99];char alp[7][5]={"MON","TUE","WED","THU","FRI","SAT","SUN"... 阅读全文
posted @ 2015-03-07 17:20 Evence 阅读(184) 评论(0) 推荐(0)
PAT:1001. A+B Format (20) AC
摘要:#includeint main(){ int a,b; scanf("%d%d",&a,&b); int sum=a+b; if(sum=1000000) //【思维】,两个数字在:-1000000 =1000) printf("%d,%03d",sum/1000,... 阅读全文
posted @ 2015-03-07 17:10 Evence 阅读(116) 评论(0) 推荐(0)
PAT:1052. Linked List Sorting (25) AC
摘要:#include#include#includeusing namespace std;struct node{ int address; int data; int next; bool tag;}Node[100066];bool cmp(node a,node b){ if(a.ta... 阅读全文
posted @ 2015-03-07 17:04 Evence 阅读(129) 评论(0) 推荐(0)
PAT:1080. Graduate Admission (30) AC
摘要:#include#include#includeusing namespace std;struct Student{ int GE,GI,sum,rank,ID; int prefer[6];}STU[40066];struct School{ int want; //各学校招... 阅读全文
posted @ 2015-03-07 16:37 Evence 阅读(188) 评论(0) 推荐(0)
PAT:1075. PAT Judge (25) AC
摘要:#include#include#includeusing namespace std;struct Student{ int ID; int score[6]; int perfect; int sum; int rank; bool tag;}S[10066];int p[6]; ... 阅读全文
posted @ 2015-03-07 15:49 Evence 阅读(239) 评论(0) 推荐(0)
PAT:1010. 一元多项式求导 (25) AC
摘要:#include#include#includeusing namespace std;int main(){ int arr[2111]; fill(arr,arr+2111,0); int n=0,tmp; while(scanf("%d",&tmp)!=EOF) //存储系数... 阅读全文
posted @ 2015-03-07 14:51 Evence 阅读(939) 评论(0) 推荐(0)
PAT:1076. Forwards on Weibo (30) AC
摘要:#include#include#include#includeusing namespace std;const int MAX=1010;bool tag[MAX]; //标记BFS是是否被访问过struct node{ int ID; //编号 int layer; ... 阅读全文
posted @ 2015-03-07 03:37 Evence 阅读(189) 评论(0) 推荐(0)
PAT:1086. Tree Traversals Again (25) AC
摘要:#include#include#includeusing namespace std;const int MAX=50;int n,cnt=0; //n个节点,cnt在后序输出的时候控制空格数量用int PRE[MAX],IN[MAX]; //先序,中序int preI,inI; ... 阅读全文
posted @ 2015-03-07 02:10 Evence 阅读(149) 评论(0) 推荐(0)
PAT:1020. Tree Traversals (25) AC
摘要:#include#include#includeusing namespace std;int POST[32]; //存放后序遍历int IN[32]; //存放中序遍历int n; //节点数struct node{ int data; node* ... 阅读全文
posted @ 2015-03-07 00:43 Evence 阅读(163) 评论(0) 推荐(0)
PAT:1051. Pop Sequence (25) AC
摘要:#include#include#includeusing namespace std;stack str; int putin[1010]; //暂存查询的序列int main(){ int m,n,k; //栈容量m,栈序列1-n,查询k次 scanf("%d%... 阅读全文
posted @ 2015-03-06 21:09 Evence 阅读(161) 评论(0) 推荐(0)
PAT:1063. Set Similarity (25) AC
摘要:#include#includeusing namespace std;set str[51]; //最大51个集合 void compare(int s1,int s2){ int different=str[s1].size(),same=0; //初始化并集元素为s1元素个数... 阅读全文
posted @ 2015-03-06 18:59 Evence 阅读(130) 评论(0) 推荐(0)
PAT:1017. A除以B (20) AC
摘要:#include#includechar n[1010]; //暂存输入的大整数字符串int num[1010]; //暂存可以运算的各位数字int cnt=0; //记录数字个数int chu; //除数int main(){ scanf("%s %d",n,&c... 阅读全文
posted @ 2015-03-06 17:06 Evence 阅读(158) 评论(0) 推荐(0)
PAT:1015. Reversible Primes (20) AC
摘要:#include#include#includeusing namespace std;int D[111]; //存放拆解的数字int DI=0; //D的数组下标bool isPrime(int n){ if(n<=1) return 0; int ... 阅读全文
posted @ 2015-03-06 11:48 Evence 阅读(116) 评论(0) 推荐(0)
PAT:1019. 数字黑洞 (20) AC(同甲级1069)
摘要:#include#includeusing namespace std;const int AIM=6174;int n;int arr[4];bool NonIncreasingOrder(int a,int b){ return a>b;}bool NonDecreasingOrder(int... 阅读全文
posted @ 2015-03-05 20:08 Evence 阅读(465) 评论(0) 推荐(0)
PAT:1069. The Black Hole of Numbers (20) AC
摘要:#include#includeusing namespace std;const int AIM=6174;int n;int arr[4];bool NonIncreasingOrder(int a,int b){ return a>b;}bool NonDecreasingOrder(int... 阅读全文
posted @ 2015-03-05 20:06 Evence 阅读(104) 评论(0) 推荐(0)
PAT:1008. Elevator (20) AC
摘要:#includeint main(){ int n,ans=0,now=0; //要停n层,ans是总时间,now代表当前层数 scanf("%d",&n); for(int i=0 ; inow) //上楼,每上一层6秒 { ans+=(tmp... 阅读全文
posted @ 2015-03-05 17:24 Evence 阅读(107) 评论(0) 推荐(0)
PAT:1052. Linked List Sorting (25) 部分错误
摘要:#include#include#includeusing namespace std;struct node{ int address; int data; int next; bool tag;}Node[100066];bool cmp(node a,node b){ re... 阅读全文
posted @ 2015-03-05 12:14 Evence 阅读(133) 评论(0) 推荐(0)
PAT:1032. Sharing (25) AC
摘要:#include#include#includestruct node{ char data; int next; bool tag;}Node[100066];int main(){ int add1,add2,n; //连表1首地址, scanf("%d%d%d",&... 阅读全文
posted @ 2015-03-05 03:16 Evence 阅读(129) 评论(0) 推荐(0)
PAT:1059. Prime Factors (25) AC
摘要:#include#include#include#includeusing namespace std;const int MAX=100010; //int型素数一定在这个范围内int PrimeArr[MAX]; //素数表int cnt=0; //... 阅读全文
posted @ 2015-03-05 01:25 Evence 阅读(178) 评论(0) 推荐(0)
素数表(筛选法)
摘要:#include#includeusing namespace std;bool arr[101]; //标记是否为素数:false就是素数,true就不是素数void isF(){ for(int i=2 ; i<101 ; ++i) { if(arr[i]==false) ... 阅读全文
posted @ 2015-03-04 16:09 Evence 阅读(202) 评论(0) 推荐(0)
PAT:1048. Find Coins (25)(双指针法) AC
摘要:#include#includeusing namespace std;int arr[100066];int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=0 ; i<n ; ++i) scanf("%d",&arr[i]); sor... 阅读全文
posted @ 2015-03-04 01:42 Evence 阅读(115) 评论(0) 推荐(0)
PAT:1048. Find Coins (25)(二分查找) AC
摘要:#include#includeusing namespace std;int arr[100066];int FIND(int l,int r,int aim) //二分查找,从l到r,查找aim{ int mid; while(l<=r) { mid=(l+r)/2; i... 阅读全文
posted @ 2015-03-04 01:28 Evence 阅读(96) 评论(0) 推荐(0)
PAT:1048. Find Coins (25)(哈希表法) AC
摘要:#include#includeint HARSH[1066];int main(){ memset(HARSH,0,sizeof(HARSH)); int n,m; scanf("%d%d",&n,&m); for(int i=0 ; i0) { if(i==m-i && ... 阅读全文
posted @ 2015-03-04 00:38 Evence 阅读(157) 评论(0) 推荐(0)
PAT:1029. Median (25) AC
摘要:#include#includeusing namespace std;int arr1[1000066];int arr2[1000066];int main(){ int n1,n2; scanf("%d",&n1); for(int i=0 ; i<n1 ; ++i) { sca... 阅读全文
posted @ 2015-03-03 23:43 Evence 阅读(128) 评论(0) 推荐(0)
PAT:1005. 继续(3n+1)猜想 (25) AC
摘要:#include#includeusing namespace std;bool HARSH[10066]; //实际上申请来之后初试都是falsebool cmp(int a,int b){ return a>b;}int main(){ fill(HARSH,HARSH+1066,... 阅读全文
posted @ 2015-03-03 12:27 Evence 阅读(160) 评论(0) 推荐(0)
PAT:1050. String Subtraction (20) AC
摘要:#include#include#includeusing namespace std;bool HARSH[260]; //实际上申请来之后初试都是falseint main(){ fill(HARSH,HARSH+260,true); char str1[10066]; char... 阅读全文
posted @ 2015-03-02 22:34 Evence 阅读(102) 评论(0) 推荐(0)
PAT:1041. Be Unique (20) AC “段错误:可能是数组开的不够大”
摘要:#include#includeint harsh[10066];int arr[100066];int main(){ memset(harsh,0,sizeof(harsh)); memset(arr,0,sizeof(arr)); int n; scanf("%d",&n); for... 阅读全文
posted @ 2015-03-02 21:25 Evence 阅读(263) 评论(0) 推荐(0)
PAT:1033. 旧键盘打字(20) AC
摘要:#include#include#includeusing namespace std;int harsh[300];char str1[100066],str2[100066];int main(){ fill(harsh,harsh+300,true); //初始化全都是好的 gets... 阅读全文
posted @ 2015-03-02 20:51 Evence 阅读(244) 评论(0) 推荐(0)
PAT:1029. 旧键盘(20) AC
摘要:#include#includebool HARSH[256]={false}; //标记字符,初始化都未输出过int main(){ char str1[100],str2[100],tmp[100]; gets(str1); gets(str2); int len1=strle... 阅读全文
posted @ 2015-03-02 19:26 Evence 阅读(185) 评论(0) 推荐(0)
PAT:1080. Graduate Admission (30) 全错
摘要:#include#include#includeusing namespace std;struct Student{ int GE,GI,sum,rank,ID; int prefer[6];}STU[40066];struct School{ int want; //各学校招... 阅读全文
posted @ 2015-03-02 16:22 Evence 阅读(261) 评论(0) 推荐(0)
PAT:1080. Graduate Admission (30) 部分错误(录取以学校为导向而不是考生志愿为导向导致的错误)
摘要:#include#include#includeusing namespace std;int want[106]; //各学校招生人数struct Student{ int GE,GI,sum,rank,ID; int prefer[6]; bool R; /... 阅读全文
posted @ 2015-03-02 15:01 Evence 阅读(248) 评论(0) 推荐(0)
PAT:1083. List Grades (25) AC
摘要:#include#includeusing namespace std;struct Student{ char name[15]; char ID[15]; int gread;}STU[66666];bool cmp(Student a,Student b){ return a.grea... 阅读全文
posted @ 2015-03-02 11:21 Evence 阅读(113) 评论(0) 推荐(0)
PAT:1075. PAT Judge (25) 炒鸡复杂
摘要:#include#include#includeusing namespace std;struct Student{ int ID; int score[6]; int perfect; int sum; int rank;}S[10066];int p[6]; //1-5存题号1... 阅读全文
posted @ 2015-03-02 11:20 Evence 阅读(114) 评论(0) 推荐(0)
PAT:1055. The World's Richest (25) AC
摘要:#include#include#includeusing namespace std;struct Person{ char name[10]; int age,money;}P[100010];bool cmp(Person a,Person b){ if(a.money!=b.money... 阅读全文
posted @ 2015-03-01 22:47 Evence 阅读(113) 评论(0) 推荐(0)
PAT:1028. List Sorting (25) AC
摘要:#include#include#includeusing namespace std;struct Student{ char ID[10]; char name[10]; int gread;}STU[100010];bool cmp1(Student a,Student b){ ret... 阅读全文
posted @ 2015-03-01 20:42 Evence 阅读(133) 评论(0) 推荐(0)
PAT:1025. PAT Ranking (25) AC
摘要:#include#include //【warning】刚开始少了这个头文件,但是VS2010中被系统自动优化没有察觉#includeusing namespace std;struct Student{ char ID[15]; int score,final_rank,lo... 阅读全文
posted @ 2015-03-01 13:39 Evence 阅读(169) 评论(0) 推荐(0)