随笔分类 -  ACM-HDU题集

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2095和google入围赛的一道题一摸一样啊!View Code #include<iostream>using namespace std;int sum ,a;int n , i;int main(){ while(scanf("%d" , &n)!=EOF, n) { sum=0; for(i=0;i<n;i++) { scanf("%d",&a); sum=sum^a; } printf("%d\n",sum 阅读全文
posted @ 2011-06-06 14:21 聊聊IT那些事 阅读(410) 评论(0) 推荐(0) 编辑
摘要:View Code #include<iostream>char ch[51][51];using namespace std;int main(){ int t; int n , m , k=0 ; int i,j; cin>>t; while(t--) { cin>>n>>m; for(i=0;i<n; i++) cin>>ch[i]; int j , i , sign = 0 ; int ans=0; for( i = 0 ; i < n ; i++ ) { for( j = 0 ; j < m ; j++ ) 阅读全文
posted @ 2011-05-22 20:52 聊聊IT那些事 阅读(617) 评论(0) 推荐(0) 编辑
摘要:View Code #include<iostream>#include<cstring>using namespace std;typedef long long ll;int p[100001] , tem[100001] ,t;void Init(){ memset(p,0,sizeof(p)); for(ll i=2; i<=100000; i++) { if( !p[i] ) { for( ll j = 2 ; j*i<=100000 ; j++ ) p[j*i]=1; } } t=0; for(int i=2;i<1000000;i++) 阅读全文
posted @ 2011-05-20 17:41 聊聊IT那些事 阅读(270) 评论(0) 推荐(0) 编辑
摘要:都是基础知识!http://acm.hdu.edu.cn/showproblem.php?pid=2057看了一位dn的解释,借鉴了:http://hi.baidu.com/gminking/blog/item/691ee158d213754dfbf2c016.html/cmtid/881e0f308ee322345bb5f5a4题目求的是十六进制的加法。刚开始想的是把十六进制转化为十进制,进行加法运算后,再转化为十六进制。后来发现自己忘了C中存在十六进制的输入输出(%X,%x)。所以这题可以直接用十六进制输入,然后进行十六进制的运算(其实不管是什么进制,在计算机中都是以二进制来计算的,只是按 阅读全文
posted @ 2011-05-13 21:05 聊聊IT那些事 阅读(1203) 评论(0) 推荐(0) 编辑
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3501View Code #include<iostream>#include<algorithm>#include<string.h>#include<cstdio>using namespace std;char a[][15]={"0", "I", "II", "III", "IV", "V", &q 阅读全文
posted @ 2011-05-01 17:22 聊聊IT那些事 阅读(382) 评论(1) 推荐(0) 编辑
摘要:http://acm.fzu.edu.cn/problem.php?pid=2014好办法!View Code #include"iostream"using namespace std;int today[]={0,31,28,31,30,31,30,31,31,30,31,30,31};bool L_y(int year){ if(year%4==0&&year%100||year%400==0) return true; return false;}int main(){ int n; while(scanf("%d",&n 阅读全文
posted @ 2011-04-30 11:08 聊聊IT那些事 阅读(269) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1038简单题,关键是读懂题;View Code #include"iostream"#define Pi 3.1415927using namespace std;int main(){ double d,c,t; double sum ,v; int j=0; while(scanf("%lf%lf%lf",&d,&c,&t)!=EOF) { if(c==0) break; sum=(Pi*d*c)/(12*5280); v=1.0*(sum* 阅读全文
posted @ 2011-04-29 07:32 聊聊IT那些事 阅读(505) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2565简单题:i+j<n-1,是对图形的上半部分空格的控制。i>j , 是对图形下半部分空格的控制。View Code #include"iostream"using namespace std;int main(){ int t; int n; cin>>t; while(t--) { int i,j; cin>>n; for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i==j||i+j==n-1) cout 阅读全文
posted @ 2011-04-27 08:49 聊聊IT那些事 阅读(316) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2100一个26进制的大数加法,View Code #include<iostream>#include<cmath>#define M 201using namespace std;char ch1[M],ch2[M];int a[M] ,b[M] ;int c[M];int i,j,k;int main(){ while(cin>>ch1>>ch2) { int L1=strlen(ch1); int L2=strlen(ch2); int flag=0; / 阅读全文
posted @ 2011-04-25 17:58 聊聊IT那些事 阅读(421) 评论(0) 推荐(0) 编辑
摘要:末尾的0可以直接输出,j精度问题减小了不少,这样相对效率高些! 不错的方法啊!View Code #include"stdio.h"#include"math.h"int _Max(int x, int y){ return x>y?x:y;}int main(){ int t; int n,m,i; int a[31]; int sum; int mark,x; scanf("%d",&t); while(t--) { scanf("%d %d",&n,&m); for(i=1;i& 阅读全文
posted @ 2011-04-25 15:19 聊聊IT那些事 阅读(321) 评论(0) 推荐(0) 编辑
摘要:纯规律题:找到n=3时,分割数为20,从而可发现2,8, 20之间差的关系正好是6的倍数。View Code #include"iostream"using namespace std;int a[10000];int main(){ int t; int n; cin>>t; while(t--) { cin>>n; a[1]=2; for(int i=2;i<=n;i++) a[i]=a[i-1]+6*(i-1); cout<<a[n]<<endl; } return 0;} 阅读全文
posted @ 2011-04-22 19:01 聊聊IT那些事 阅读(313) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1406需要注意的地方:num1和num2的大小关系不确定。View Code #include"iostream"using namespace std;int v[10000];void Init(){ int i,j; memset(v,0,sizeof(v)); for(i=2; i<10000; i++) { int sum=0; for(j=1;j<=i/2;j++) { if(i%j==0) sum+=j; } if(sum==i) { v[i]=1; } }}in 阅读全文
posted @ 2011-04-22 18:33 聊聊IT那些事 阅读(271) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2054很烦的题~~View Code #include"iostream"#include"string"using namespace std;int i,j,L1,L2;char a[20000],b[20000];int main(){ while(scanf("%s %s",&a,&b)!=EOF) { if(a[0]=='-'&&b[0]=='-'||a[0]!='-& 阅读全文
posted @ 2011-04-22 18:15 聊聊IT那些事 阅读(672) 评论(0) 推荐(0) 编辑
摘要:View Code #include"iostream"#define M 20000#include"algorithm"using namespace std;int c[M];int main(){ int n,m; int a,b; int i,j; while(cin>>n>>m) { int k=0; for(i=0;i<n;i++) { cin>>a; c[k++]=a;} for(i=0;i<m;i++) { cin>>b; c[k++]=b;} sort(c,c+k); for 阅读全文
posted @ 2011-04-22 18:14 聊聊IT那些事 阅读(163) 评论(0) 推荐(0) 编辑
摘要:View Code #include"iostream"using namespace std;int main(){ char ch[1000]; char a[1000][100]; int i,j; int used[1000]; while(gets(ch)) { if(strcmp(ch,"#")==0) break; int L=strlen(ch); int start=0,end=L-1; for(i=0;i<L;i++) if(ch[i]!=' ') {start=i; break;} for(i=L-1;i> 阅读全文
posted @ 2011-04-22 16:57 聊聊IT那些事 阅读(455) 评论(0) 推荐(0) 编辑
摘要:水题一道,注意闰年和平年的判断。View Code #include"iostream"using namespace std;int main(){ int y,m,d; while(scanf("%d/%d/%d",&y,&m,&d)!=EOF) { int sum=0,i; for(i=1;i<m;i++) { switch(i) { case 1: sum+=31; break; case 2: { if(y%4==0&&y%100||y%400==0) { sum+=29; } else sum+= 阅读全文
posted @ 2011-04-21 16:04 聊聊IT那些事 阅读(517) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2674小技巧 :当数很大时mod2009就为0了。。。。。。。。View Code #include"iostream"using namespace std;int main(){ int n; int i; while(cin>>n) { int mul=1; if(n<=1000) { for(i=1;i<=n;i++) { mul*=i%2009; mul%=2009; } } else mul=0; cout<<mul<<endl; 阅读全文
posted @ 2011-04-20 16:13 聊聊IT那些事 阅读(288) 评论(0) 推荐(0) 编辑
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2104思路分析:m和n互质即可。与hdu1222相同 http://acm.hdu.edu.cn/showproblem.php?pid=1222 阅读全文
posted @ 2011-04-14 10:00 聊聊IT那些事 阅读(252) 评论(0) 推荐(0) 编辑
摘要:单词倒置Time Limit:1000MS Memory Limit:65536KTotal Submit:68 Accepted:8 Description 请编制程序实现下面的功能:将一篇英文文章中的以空格或标点符号为分隔的所有单词进行倒排,同时去除标点符号,之后输出已处理的英语文章(应不含标点符号)。Input 有多组数据,每组一行,每组就是一篇小文章。每篇小文章都由大写字母、小写字母、空格及标点符号组成,遇到#时表示输入结束。Output 每组输出其对应的字符串,其单独成行。Sample Input You He MeI am a student.#Sample Output Me H 阅读全文
posted @ 2011-04-11 18:25 聊聊IT那些事 阅读(409) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1256View Code #include"iostream"using namespace std;int n,m;int i,j;char a[10];int y; int d; // d表示行的宽度void fun1(){ for( i=0;i<d-y;i++) { if(i<m/6+1) printf(" "); else printf("%s",a); } printf("\n");}void fun2(in 阅读全文
posted @ 2011-04-07 17:07 聊聊IT那些事 阅读(382) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示