X-man

导航

随笔分类 -  ACM--水题也wrong过

1 2 下一页

hdu 4891 The Great Pan
摘要:#include#include#include#includeusing namespace std;string s;char tmp[2000000];int main(){ int snum;//s int lnum;//{ int n; int i,j; __... 阅读全文

posted @ 2014-07-29 19:11 雨钝风轻 阅读(183) 评论(0) 推荐(0)

hdu 1567 2006 (题意理解容易出错)
摘要:#include#include#includeusing namespace std;struct Node{ int x,y;} p;bool cmp(Node a,Node b){ if(a.xve;int main(){ int n,m; int x,y,flag; int i,j; while(scanf("%d",&n)!=EOF) { flag=1; ve.clear(); m=n; n=n*(n-1)/2; for(i=0; iy) { ... 阅读全文

posted @ 2013-10-02 19:47 雨钝风轻 阅读(297) 评论(0) 推荐(0)

hdu 2206 IP的计算(最全的注意事项)
摘要:注意: 1.非法字符(包括空格)如下都是错的 A.145.124.4 192.168.18 123(用scanf输入的话,则接收的是:192.168.18)2.'.'有且仅有3个,且不能连续出现,也不能首位,末位出现,如下都是错的123..123.45.124.45.645.134.4.3.不能连续出现4个非 '.'的字符 如下都是错的192.168.0123.414.分成四段数字,各数字#includechar s[110];int main(){ int sl; while(gets(s)) { sl=strlen(s); ... 阅读全文

posted @ 2013-08-10 21:10 雨钝风轻 阅读(500) 评论(0) 推荐(0)

hdu 2519 新生晚会 (求排列组合时容易溢出)
摘要:#include#includeusing namespace std;void cal(int n,int m){ long long ans=1; m=min(m,n-m); int j=m; for(int i=n;m>0;m--,i--) { ans*=i; } for(int i=1;in)printf("0\n"); else cal(n,m); } return 0;}View Code 注意此写法long long也会溢出!!!!!!!!!!!!!!#include#includeusing na... 阅读全文

posted @ 2013-08-10 19:58 雨钝风轻 阅读(555) 评论(0) 推荐(0)

hdu 1106 排序
摘要:#include#include#includeusing namespace std;int ans[1100];int ai;int change(char *a){ int i,sum=0; int al=strlen(a); for(i=0;i<al;i++) { sum=sum*10+a[i]-'0'; } ans[ai++]=sum; //printf("\n#%d\n",sum); return 0;}int main(){ char s[1100],ss[1100]; int i; while(sc... 阅读全文

posted @ 2013-08-01 11:11 雨钝风轻 阅读(163) 评论(0) 推荐(0)

hdu 2132 An easy problem
摘要:#includelong long sum[100010];int main(){ int n; int i; sum[0]=0,sum[1]=1; for(i=2; i=0) { printf("%I64d\n",sum[n]); } return 0;}****需注意的地方:if(i%3==0)sum[i]=sum[i-1]+(long long)i*i*i; 阅读全文

posted @ 2013-07-09 20:36 雨钝风轻 阅读(222) 评论(0) 推荐(0)

hdu Lovekey(水题)
摘要:#include<stdio.h>#include<string.h>int a[210];int main(){ char s1[210],s2[210]; int l1,l2,i,j,k; while(scanf("%s %s",s1,s2)!=EOF) { l1=strlen(s1); l2=strlen(s2); int l11=0,l22=0; while(s1[l11]=='A')l11++; while(s2[l22]=='A')l22++; for(i=l1-1,j=l2... 阅读全文

posted @ 2013-06-17 10:40 雨钝风轻 阅读(264) 评论(0) 推荐(0)

hdu 3349 lazy gege
摘要:#include<stdio.h>#include<math.h>int main(){ int _case; double l,a,b; scanf("%d",&_case); while(_case--) { scanf("%lf %lf %lf",&l,&a,&b); if(a<b) { double t=b; b=a; a=t; } double d=sqrt(2.0)*l/2; if(d>=b/2) ... 阅读全文

posted @ 2013-05-30 14:58 雨钝风轻 阅读(226) 评论(0) 推荐(0)

hdu 4545 魔法串
摘要:#include<stdio.h>#include<string.h>#include<map>using namespace std;char a[1010];char b[1010];//map<char,char>m;char c[2020];//multimap<char,char>::iterator it;int main(){ int _case,n; char x,y; int al,bl,i,j,ij; scanf("%d",&_case); for(ij=1;ij<=_case;i 阅读全文

posted @ 2013-05-18 16:46 雨钝风轻 阅读(254) 评论(0) 推荐(0)

XiangTan University1163 查询成绩
摘要:#include<stdio.h>#include<string>#include<string.h>#include<iostream>using namespace std;string s1,s2;int main(){ char a[200]; char b[200]; int i,j,k; while(scanf("%s %s",a,b+1)!=EOF) { b[0]='*';//正确密码的片段(可能首缺) s1=a; s2=b; i=0,j=0,k=0; //s2.push_fron... 阅读全文

posted @ 2013-05-13 11:51 雨钝风轻 阅读(192) 评论(0) 推荐(0)

硬币水题II
摘要:#include<stdio.h>int main(){ int _case; double p; scanf("%d",&_case); while(_case--) { scanf("%lf",&p); printf("%.2lf\n",1/p/(1-p)); } return 0;}http://www.bnuoj.com/bnuoj/problem_show.php?pid=29064 阅读全文

posted @ 2013-04-30 21:23 雨钝风轻 阅读(187) 评论(2) 推荐(0)

沙漠之旅
摘要:#include<stdio.h>#include<algorithm>#include<iostream>using namespace std;int a[1005];int main(){ int _case,l,x,n; int i,j,k,g; scanf("%d",&_case); while(_case--) { scanf("%d %d %d",&l,&x,&n); for(i=0;i<n;i++) scanf("%d",&a[i]); 阅读全文

posted @ 2013-04-30 21:11 雨钝风轻 阅读(231) 评论(2) 推荐(0)

hdu 2832 (Snail’s trouble)
摘要:#include<stdio.h>#include<math.h>const double esp=1.0e-10;double a[400];int main(){ int k; int i; a[0]=0; for(i=1;i<400;i++) a[i]=a[i-1]+1.0/i; int b[11]={441,710,1230,2336,4983,12367,37568,150661, 898515,9717617,272400600}; while(scanf("%d",&k)!=EOF) //for(k=5;k<101; 阅读全文

posted @ 2013-04-26 14:43 雨钝风轻 阅读(306) 评论(0) 推荐(0)

hdu 1170(Balloon Comes!)
摘要:#include<stdio.h>#include<math.h>#define zero 1e-10int main(){ int _case; char ys; int a,b,c; double d; while(scanf("%d",&_case)) { while(_case--) { getchar(); scanf("%c %d %d",&ys,&a,&b); if(ys=='+')printf("%d\n",a+b); ... 阅读全文

posted @ 2013-04-25 16:00 雨钝风轻 阅读(224) 评论(0) 推荐(0)

hdu 1407(测试你是否和LTC水平一样高)
摘要:#include<stdio.h>int main(){ int sum; int x,y,z; while(scanf("%d",&sum)!=EOF) { for(x=1;x<100;x++) for(y=1;y<100;y++) for(z=1;z<100;z++) if(x*x+y*y+z*z==sum)goto R; R:printf("%d %d %d\n",x,y,z); } return 0;} 阅读全文

posted @ 2013-04-24 12:58 雨钝风轻 阅读(198) 评论(0) 推荐(0)

hdu 2094(产生冠军)
摘要:思路一:产生冠军的条件:(1)获胜的人没输过一次(2)最终获胜的人只有一个思路二:观察一下,可以看到其实只要总元素数-失败者==1就可以输出YES了。。思路三:左边的为胜利者,右边的为失败者,如果左边的胜利者只有一个没在右边出现过,那么这个就是产生的冠军,否则产生不了思路一:#include<stdio.h>#include<map>#include<string>#include<iostream>using namespace std;string s1,s2;map<string,int>mv;map<string,int 阅读全文

posted @ 2013-04-22 21:33 雨钝风轻 阅读(186) 评论(0) 推荐(0)

相似字符串
摘要:http://acm.buaa.edu.cn/problem/529/#include<stdio.h>#include<string>#include<iostream>using namespace std;string s1,s2;string ::iterator it;int main(){ int m,n; int _case; scanf("%d",&_case); for(int i=1;i<=_case;i++){ cin>>s1>>s2; int mi=s2.size(); /.. 阅读全文

posted @ 2013-04-22 18:18 雨钝风轻 阅读(150) 评论(0) 推荐(0)

hdu 1172(猜数字)一千个WA的缘由
摘要:思路一: 先初始化b数组1000~9999; 然后每输入一个条件就更新b数组; 最后看b数组中的个数,为1 yes;or no; @@@@数组更新较难处理思路二: 保存所有条件; 看1000~9999中每个数能过全部的条件 保存符合条件的个数; 较优: for(int k=0;k<4;k++) { int t=a[k]-'1'+1;//化为整数 if(j1==t) ... 阅读全文

posted @ 2013-04-22 16:34 雨钝风轻 阅读(315) 评论(0) 推荐(0)

hdu 4505(小Q系列故事——电梯里的爱情)
摘要:#include<stdio.h>#include<string.h>#include<map>#include<algorithm>using namespace std;int main(){ int C,N,x,k,h; int time; map<int ,int>m; map<int ,int>::iterator it; scanf("%d",&C); while(C--) { m.clear(); k=0;//记录不同的层数 scanf("%d",&N) 阅读全文

posted @ 2013-04-18 16:29 雨钝风轻 阅读(270) 评论(0) 推荐(0)

hdu 1557(权利指数)
摘要:思路: **用二进制表示状态,暴力枚举! 傻瓜式算法描述: 1.用二进制列举所有的状态 2.找票数之和大于总票数一半的状态 3.在这些状态中,若去掉某个小团体之后,不满足票数之和大于总票数一半,则为关键团体,加一。#include<stdio.h>#include<string.h>int data[21];int ans[21];int main(){ int n,T; int i,j,sum,isum,tmp; float bsum; int m;//记录所有的状态 scan... 阅读全文

posted @ 2013-04-18 15:49 雨钝风轻 阅读(233) 评论(0) 推荐(0)

1 2 下一页