随笔分类 -
无聊题
HDU 1279 验证角谷猜想
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1279按要求模拟View Code #include <stdio.h>int main(){ int t,n,p,f,f1; scanf("%d",&t); while(t--) { f=f1=1; scanf("%d",&n); p=n; while(n) { if(n%2&&n!=1){ f1=0; break; ...
阅读全文
HDU 3783 ZOJ
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3783View Code #include <stdio.h>#include <stdlib.h>#include <string.h> int main(){ int n,i; int cntZ,cntO,cntJ; int len; char str[200]; while(gets(str)) { if(str[0]=='E')break; len=strlen(str); cntZ=cntO=cntJ=0; ...
阅读全文
HDU 3782 xxx定律
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3782View Code #include <stdio.h>#include <stdlib.h>int main(){ int n; while(scanf("%d",&n),n) { int cnt=0; while(1) { if(n==1)break; if(n&1) n=(3*n+1)>>1; else n>>=1...
阅读全文
HDU 3785 寻找大富翁
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3785View Code #include <stdio.h>#include <stdlib.h>#define INF 200000000int cmp(const void*a,const void*b){ return *(int*)b-*(int*)a;}int a[110000];int main(){ int n,m; while(scanf("%d%d",&n,&m),(n||m)) { for(int i=0;i<100001
阅读全文
HDU 2399 GPA
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2399最短路最小生成树神马的几道题纠结了几个小时,换换心情吧。直接按题目要求做。View Code #include <stdio.h>#include <string.h>int main(){ char str[300]; int len,i; int s,f,cnt; while(gets(str)) { len=strlen(str); s=f=cnt=0; for(i=0;i<len;i++) { ...
阅读全文
HDU 1202 The calculation of GPA
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1202刚开始没看到输入实数。。。汗、、、View Code #include <stdio.h>int main(){ double s[100],p[100]; int n,i; double ss,sp; int cnt; while(~scanf("%d",&n)) { cnt=ss=sp=0; for(i=0;i<n;i++) { scanf("%lf%lf",s+i,p+i); ...
阅读全文
HDU 1234 开门人和关门人
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1234和祖宗随机题号PK,由于这题first和end的初值赋反了,导致调试10分钟,最后以惨败收场。。。View Code #include <stdio.h>#include <string.h>#define INF 100000000int main(){ int t,n,i; int hb,mb,sb; int he,me,se; int first,end; char name[2][200],namec[200]; scanf("%d",&t);
阅读全文
HDU 2131 Probability
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2131求字母在单词中出现的概率,无视大小写View Code #include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ char sp,word[210]; int i,len,cnt; while(~scanf("%c%s%*c",&sp,word)) { len=strlen(word); cnt=0; for(i=0;i<len;i++) ...
阅读全文
HDU 1196 Lowest Bit
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1196按要求直接做View Code #include <stdio.h>int pow(int a,int b){ int i,s=1; for(i=0;i<b;i++) s*=a; return s;}int main(){ int n,cnt,y; while(scanf("%d",&n),n) { cnt=0; while(1) { y=n%2; n/=2; ...
阅读全文
HDU 2521 反素数
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2521题目蒙人,这题和反素数没关系求一个区间内因子数最多的最小的数View Code #include <stdio.h>#include <string.h>int main(){ int t,a,b,i,j; int cnt[6000]; int max,si; memset(cnt,0,sizeof(cnt)); cnt[1]=1; for(i=2;i<5001;i++) { for(j=2;j<=i/2;j++) if(i%...
阅读全文
HDU 1564 Play a game
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1564View Code #include <stdio.h>int main(){ int n; while(scanf("%d",&n),n) { if(n%2==0) printf("8600\n"); else printf("ailyanlu\n"); } return 0;}
阅读全文
HDU 1032 The 3n + 1 problem
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1032可能存在i>j的情况,此情况下i,j要按原顺序输出View Code #include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>int main(){ int a,b,n,cnt,max,t,f; while(~scanf("%d%d",&a,&b)) { max=f=1; if(a>b) { t=a; a=b; ...
阅读全文
HDU 1062 Text Reverse
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1062每个单词逆序输出就可以View Code #include <stdio.h>#include <string.h> #include <stdlib.h>#include <math.h>int main() { int t,len; int i,j; char a[1100]; scanf("%d%*c",&t); while(t--) { gets(a); len=strlen(a); for(i=0;i<le...
阅读全文
HDU 4150 Powerful Incantation
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4150查找不重复字串View Code #include <stdio.h>#include <string.h> #include <stdlib.h>#include <math.h>char a[1100000],b[10]; int main() { int t,ans; int len1,len2; int cnt; scanf("%d%*c",&t); while(t--) { scanf("%s%s%*c&qu
阅读全文
HDU 4144 Bacon's Cipher
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4144数字对应1,字母对应0,五位一算。View Code #include <stdio.h>#include <string.h> #include <stdlib.h>int pow(int a,int b) { int i,s=1; for(i=0;i<b;i++) s*=a; return s; }char a[11000]; char tab[30]={'A','B','C','D','
阅读全文
HDU 1720 A+B Coming
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=172016进制输入,10进制输出View Code #include <stdio.h>#include <string.h> #include <stdlib.h>#include <math.h>int main() { int a,b; while(~scanf("%x%x",&a,&b)) printf("%d\n",a+b); return 0; }
阅读全文
POJ 1004 Financial Management
摘要:http://poj.org/problem?id=1004求12个数的平均数、、、太无耻了View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { double s,a[13]; int i; while(~scanf("%lf",&a[0])) { s=a[0]; for(i=1;i<12;i++) { scanf("%lf",a+i); s+=a[...
阅读全文
POJ 2027 No Brainer
摘要:http://poj.org/problem?id=2027判断a<b......脸皮这两天又厚了不少、、、这种题也拿来充数、、、忏悔ingView Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { int t; int a,b; scanf("%d",&t); while(t--) { scanf("%d%d",&a,&b); if(a<b
阅读全文
POJ 2017 Speed Limit
摘要:http://poj.org/problem?id=2017按题意计算路程,直接算View Code #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>int main() { int n,i; int s[20],t[20]; int ans; while(scanf("%d",&n),n!=-1) { for(i=0;i<n;i++) scanf("%d%d",s+i,t+i); ans=s[0
阅读全文
HDU 2673 shǎ崽 OrOrOrOrz
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2673排序题,汗。。。View Code #include <stdio.h>#include <stdlib.h>int cmp(const void*a,const void*b){ return *(int*)a-*(int*)b;}int a[11000];int main() { int n; int i,f,cnt1,cnt2; while(~scanf("%d",&n)) { for(i=0;i<n;i++) scanf("%d
阅读全文
|
|