
pat-a-简单模拟
文章平均质量分 66
要认认真真
这个作者很懒,什么都没留下…
展开
-
1088. Rational Arithmetic (20)
点击打开链接分数运算首先分数有3点要素:1.分母要大于02.分书为0时,分子为0,分母为13.要约分,即求最小公倍数gcd(a,b)但是a和b要取绝对值分数输出时要将假分数化为真分数时刻记着化简分数#include long long abss(long long a){ return a<0?-a:a;}long long gcd(long lon原创 2015-02-13 16:39:29 · 446 阅读 · 0 评论 -
1084. Broken Keyboard (20)
点击打开链接#include #include using namespace std;int main(){ freopen("in.txt","r",stdin); char a[100],b[100]; gets(a); gets(b); char ans[100]; bool count[128]; memset(count,0,sizeof(c原创 2015-02-08 16:54:59 · 235 阅读 · 0 评论 -
1073. Scientific Notation (20)
全过了,但是!!!代码写的太挫了,太长了!!!!!点击打开链接#include #include struct s { char qian[10000]; char hou[10000]; int qf; int hf; int keep;};int main(){ freopen("in.txt","r",stdin); char c[10010]原创 2015-02-08 16:04:46 · 275 阅读 · 0 评论 -
1001. A+B Format (20)
点击打开链接#include #define MAX 1000010char pro[MAX];char res[2*MAX];int main(){ freopen("in.txt","r",stdin); int a,b; while(scanf("%d %d",&a,&b)!=EOF){ int c=a+b; if(c!=0){ int flag=1;原创 2015-02-06 23:40:34 · 252 阅读 · 0 评论 -
1016. Phone Bills (25)
点击打开链接//用sort给stl排序sort(st.begin(),st,end(),cmp);//用sort给数组排序sort(a,a+N,cmp);有2个点段错误?!!!!#include #include #include #include #include using namespace std;map name;struct原创 2015-02-05 10:35:24 · 273 阅读 · 0 评论 -
1015. Reversible Primes (20)
点击打开链接0和1都不是素数!!!//题意真难理解!!!//首先判断23是否为素数,将其转为2进制10111// 翻转得到2进制数11101,再转为10进制得到29,判断29是否为素数#include #define MAX 100010bool prime[MAX]={0};void findp(){ prime[0]=true; prime[1]=true;原创 2015-02-07 11:00:43 · 300 阅读 · 0 评论 -
1062. Talent and Virtue (25)
点击打开链接#include #include #include using namespace std;struct s { char id[10]; int v; int t; int total;}rec[100010];int n,low,h;bool cmp(s a,s b){ if(a.total!=b.total){ return a.t原创 2015-02-06 19:32:43 · 237 阅读 · 0 评论 -
1024. Palindromic Number (25)
点击打开链接学会用reverse(c,c+n),reverse(c.begin(),c.end())在algorithm中#include #include #include using namespace std;struct bign{ int d[100]; int len; bign(){ memset(d,0,sizeof(d)); len=0原创 2015-02-09 09:55:49 · 396 阅读 · 0 评论 -
1069. The Black Hole of Numbers (20)
点击打开链接考虑输入的为3位数2位数1位数,因此要填充0还有1点没过#include #include #include #include using namespace std;struct s{ int a,b,c;};bool big(char a,char b){ return a>b;}bool lit(char a,char b){ ret原创 2015-02-08 12:19:42 · 291 阅读 · 0 评论 -
1059. Prime Factors (25)--taste
点击打开链接注意:1.对于输入为1的情况要特判2.factor在int范围内开到10就足够3.sqrt是范围,由于n后面被修改故范围要单写,且sqrt是doubleint sqr=sqrt(1.0*n);4.按照prime中的素数寻找时,当n==1是要退出5.对于本身是素数的寻找过程,由于寻找范围只在sqrt内,因此循环过程后n不变,因此要特判#in原创 2015-02-08 09:25:11 · 315 阅读 · 0 评论 -
1065. A+B and C (64bit) (20)
点击打开链接最后一点没过注意:1.大数的结构体struct bign{ int d[MAX]; int len; int flag; //结构体初始化,写在结构体内部,函数无参数无返回值,函数名为结构体名 bign(){ memset(d,0,sizeof(d)); len=0; flag=原创 2015-02-07 15:00:49 · 310 阅读 · 0 评论 -
1089. Insert or Merge (25)
点击打开链接2路归并排序:就是把序列分为k组,每组2的整数倍个,每次用sort进行排序void merge_sort(int a[]{ //因为是二路归并,所以开始step设置为2,每次倍加 //注意结束条件是step/2<num for(int step=2;step/2<num;step*=2){ //每组step个数据,进行排序 for(int i=0;i<num;原创 2015-02-13 15:29:41 · 298 阅读 · 0 评论 -
1017. Queueing at Bank (25)
点击打开链接找不到哪里错了,有3个点不过#include #include #include using namespace std;int n,w;struct mytime{ int hh,mm,ss;};struct node{ mytime come; mytime start; mytime fin; int last;}no[10010];vec原创 2015-02-15 10:38:22 · 246 阅读 · 0 评论 -
1078. Hashing (25)
点击打开链接有一点不过,感觉是hash范围有问题,如果开足够大,总能找到#include #include #include #define MAX 10010int prime[MAX];bool p[MAX];int cntp=0;void findp(){ memset(p,0,sizeof(p)); for(int i=2;i<MAX;i++){原创 2015-02-09 12:04:26 · 267 阅读 · 0 评论 -
1083. List Grades (25)
点击打开链接#include #include #include using namespace std;struct student{ char name[20]; char id[20]; int grade;};bool cmp(student a,student b){ return a.grade>b.grade;}int main(){ int原创 2015-02-09 11:10:36 · 435 阅读 · 0 评论 -
1075. PAT Judge (25)
点击打开链接2个点没过#include#include #include using namespace std;struct p{ int id; int num[5]; int total; //是否显示在列表中,没提交或者编译出错的,不显示 int list; //完美解决的题目总数 int ps;}pat[10010];int n,k,m;int原创 2015-02-07 21:58:29 · 353 阅读 · 0 评论 -
1052. Linked List Sorting (25)
点击打开链接开始find函数是自己写的,for循环查找,超时果断换用map,过了,但是仍有一点未过,结果为零也考虑了,还有什么呢?!!!#include #include#include #include using namespace std;struct no{ int val; int add; int next;}tmp[100010];vector原创 2015-02-06 09:45:33 · 280 阅读 · 0 评论 -
1081. Rational Sum (20)
点击打开链接注意这里的abs不能直接用std::abs(x)#include #include struct fraction{ int up,down;};int gcd(int a,int b){ if(b==0){ return a; }else{ return gcd(b,a%b); }}fraction reduction(fracti原创 2015-02-09 10:45:31 · 399 阅读 · 0 评论 -
1077. Kuchiguse (20)
点击打开链接开始没加fin判,导致段错误,比如2Ninjinnwaiyada T_TT_T#include #include #include using namespace std;string s[1010];char ans[300];int main(){ freopen("in.txt","r",stdin); int n; scanf("%原创 2015-02-08 21:44:45 · 256 阅读 · 0 评论 -
1023. Have Fun with Numbers (20)
3个点不过!!!!点击打开链接#include #include struct bign{ int len; int x[21]; bign(){ len=0; for(int i=0;i<21;i++){ x[i]=0; } }};bign change(char c[]){ bign big; for(int i=strlen(c)-1原创 2015-02-08 23:16:49 · 410 阅读 · 0 评论 -
1055. The World's Richest (25)
点击打开链接又点会卡时间,因此必须进行优化1.对所有人排序就要全面排序2.排序后的total是符合答案排序准则的3.因此对于ans的push过程就要加上对num的检验#include #include #include #include #include using namespace std;int n,m;struct s { char name[1原创 2015-02-06 10:28:06 · 243 阅读 · 0 评论 -
1041. Be Unique (20)
点击打开链接#include #define MAX 100010int hash[MAX]={0};int a[MAX];int main(){ freopen("in.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++){ scanf("%d",&a[i]); hash原创 2015-02-05 15:21:40 · 327 阅读 · 0 评论 -
1027. Colors in Mars (20)
点击打开链接#include char w[14]={"0123456789ABC"};char m,n;void f(int x){ if(x!=0){ n=w[x%13]; x/=13; }else{ n='0'; } if(x==0){ m='0'; }else{ m=w[x%13]; }}int main(){ int a,b,c;原创 2015-02-02 17:24:12 · 276 阅读 · 0 评论 -
1019. General Palindromic Number (20)
点击打开链接#include #include #include using namespace std;int ans[1000000];int main(){ freopen("in.txt","r",stdin); int n,k; scanf("%d %d",&n,&k); int cnt=0; while(n!=0){ ans[cnt++]=n%k;原创 2015-02-02 15:15:21 · 331 阅读 · 0 评论 -
1011. World Cup Betting (20)
点击打开链接#include #include double a[3][3];char word[3]={'W','T', 'L'};int main(){ freopen("in.txt","r",stdin); double ans=0.65; for(int i=0;i<3;i++){ double max=0; int id=-1; for(i原创 2015-02-02 10:59:06 · 228 阅读 · 0 评论 -
1025. PAT Ranking (25)
点击打开链接前面都过,最后一个不过#include #include #include using namespace std;struct s{ char id[14]; int grade; int group; int grorank; int finrank;}list[30010];bool cmpin(s a,s b){ return原创 2015-02-03 09:20:14 · 278 阅读 · 0 评论 -
1005. Spell It Right (20)
点击打开链接由于字符串较大,必须用string接收,用char[]无法申请那么大#include #include #include #include using namespace std;string x;char a[1000000];char num[][10]={"zero","one","two","three","four","five","six","se原创 2015-02-02 09:28:53 · 180 阅读 · 0 评论 -
1036. Boys vs Girls (25)
点击打开链接#include #include #define MAX 10010using namespace std;struct stu{ char name[20]; char sex; char id[20]; int grade;}list[MAX];int n;bool cmp(stu a,stu b){ if(a.sex!=b.sex){原创 2015-02-01 16:47:48 · 223 阅读 · 0 评论 -
1006. Sign In and Sign Out (25)
点击打开链接#include #include #include using namespace std;int n;struct s{ char id[20]; int inh; int inm; int ins; int outh; int outm; int outs;}rec[10000000];bool cmpin(s a,s b){ if(a.原创 2015-02-02 09:48:42 · 351 阅读 · 0 评论 -
1009. Product of Polynomials (25)
点击打开链接用map存储系数和值得关系#include #include using namespace std;map a;map b;map c;int main(){ freopen("in.txt","r",stdin); int x; scanf("%d",&x); for(int i=0;i<x;i++){ int m; double n; sc原创 2015-02-02 10:34:37 · 293 阅读 · 0 评论 -
1012. The Best Rank (25)
点击打开链接最大的坑点就是rank的排名中:对于相同分数,相同排名#include #include using namespace std;int n,m;struct de{ int id; int c; int m; int e; int a; int cr; int mr; int er; int ar;}stu[2010];bool cmp_c(de原创 2015-02-03 14:57:22 · 231 阅读 · 0 评论 -
1082. Read Number in Chinese (25)
折磨死你啊!!!!思路一,所有4位数全部预读出,但是好像没有那么大的字符数组思路二,每4位读一次这段代码没有考虑8000,800,这种数字的读法#include #include char num[10][5]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu"};char quan[][5]={"","Shi"原创 2015-02-04 10:43:59 · 443 阅读 · 0 评论 -
1058. A+B in Hogwarts (20)
点击打开链接#include int a[3];int b[3];int c[3]={0,0,0};int quan[3]={1,17,29};int main(){ freopen("in.txt","r",stdin); scanf("%d.%d.%d",&a[0],&a[1],&a[2]); scanf("%d.%d.%d",&b[0],&b[1],&b[2]); c[原创 2015-02-06 16:45:07 · 478 阅读 · 0 评论 -
1042. Shuffling Machine (20)
点击打开链接#include char c[][4]={"","S1","S2","S3","S4","S5","S6","S7","S8","S9","S10","S11","S12","S13", "H1","H2","H3","H4","H5","H6","H7","H8","H9","H10","H11","H12","H13", "C1","C2","C3","C4","C5"原创 2015-02-05 16:30:54 · 348 阅读 · 0 评论 -
1046. Shortest Distance (20)
点击打开链接最后一个超时#include #define MAX 100100int dis[MAX];int n;int main(){ freopen("in.txt","r",stdin); scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&dis[i]); } int m; scanf("%d",&m);原创 2015-02-05 17:12:01 · 221 阅读 · 0 评论 -
1050. String Subtraction (20)
点击打开链接有2点超时,但是已经用了hash,应该是m+n的复杂度啊#include #include #include using namespace std;int mark[128]={0};char a[10010],b[10010];int main(){ freopen("in.txt","r",stdin); gets(a); gets(b);原创 2015-02-05 19:29:12 · 335 阅读 · 0 评论 -
1035. Password (20)
点击打开链接#include#include struct s{ char name[20]; char pwd[20];}rec[1010];int cha[1010];int main(){ freopen("in.txt","r",stdin); int n; while(scanf("%d",&n)!=EOF){ int cnt=0; for(int原创 2015-02-05 11:44:20 · 293 阅读 · 0 评论 -
1028. List Sorting (25)
点击打开链接#include #include #include #include using namespace std;int n,s;struct rec{ char id[10]; char name[10]; int mark;}stu[100010];bool cmp_1(rec a,rec b){ return strcmp(a.id,b.id原创 2015-02-05 11:14:15 · 229 阅读 · 0 评论 -
1080. Graduate Admission (30)
点击打开链接多次读错题目!注意按照先按照排名排序,然后按照志愿是否是否满来分配招生还有2点没过sad。。。#include #include#include #include using namespace std;#define STU 40010#define SCHOOL 110int n,m,k;struct s{ int id; int ge,gi原创 2015-02-05 10:50:45 · 227 阅读 · 0 评论 -
1031. Hello World for U (20)
点击打开链接貌似n=9错了#include #include #include #include using namespace std;char c[10000];char s[10000][10000];int main(){ freopen("in.txt","r",stdin); gets(c); int n=strlen(c)-2; int max=0;原创 2015-02-03 19:49:00 · 379 阅读 · 0 评论