ACM水题
文章平均质量分 67
静默加载
优秀的判断力来自于经验,但经验来自于错误的判断。在看着别人走过的路时,思考怎么走自己的路。无私奉献不是天方夜谈,有时候,我们也可以做到。
展开
-
ACM JOJ 1007
#include using namespace std;int main(){ intnumber,n=2000; intflag=0,local; while(cin>>number) { flag=0; if(number==0) break; else if(number==1原创 2015-12-18 18:05:19 · 657 阅读 · 0 评论 -
ACM JOJ 1023
#include using namespace std;int main(){ stringa; intsum=0; while(1) { sum=0; cin>>a; if(a[0]=='0') { break; } else原创 2015-12-18 18:05:22 · 459 阅读 · 0 评论 -
ACM JOJ 1062
#include using namespace std;int main(){ inta,b,temp; intn,m; while(1) { cin>>a>>b; if(a==0&&b==0) break; if(a { temp=a;原创 2015-12-18 18:05:24 · 874 阅读 · 0 评论 -
HDOJ 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 10361037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 10731075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 11原创 2015-12-18 18:05:42 · 466 阅读 · 0 评论 -
hdoj acm 1003
#include using namespace std;int main(){ intT,t,n,flag=0; intsum,top,end; inta[100005]; cin>>T; t=0; while(t { sum=top=end=0; t++; if(flag)原创 2015-12-18 18:05:49 · 465 阅读 · 0 评论 -
hdoj acm 1008
#includeusingnamespace std;intmain(){ int N; while(cin>>N) { int time=0,from=0,to=0; if(N==0) break; for(int i=0原创 2015-12-18 18:05:52 · 516 阅读 · 0 评论 -
hdoj acm 1029
#include#includeintmain(){ int n,m,i,temp; int a[100000]={0}; while(scanf("%d",&n)!=EOF) { temp=0; for(i=0;i { scanf("%d",&m); a原创 2015-12-18 18:05:54 · 451 阅读 · 0 评论 -
hdoj acm 1555
#includeintmain(){ int n,m; int sum; while(scanf("%d%d",&n,&m)) { sum=0; if(n==0&&m==0) break; if(n==0) printf("%d\n",sum);原创 2015-12-18 18:05:57 · 464 阅读 · 0 评论 -
hdoj acm 1592
#include#include#includeusingnamespace std;intN,len;intans[10100];intmain(){ while(scanf("%d",&N)!=EOF) { memset(ans,0,sizeof(ans)); len=0; ans[0]=1;原创 2015-12-18 18:05:59 · 455 阅读 · 0 评论 -
hdoj acm 1001
#include int main(){ intflag=0; doublen,s; while(scanf("%lf",&n)!=EOF) { s=n*(1+n)/2.0; printf("%0.lf\n\n",s); } return0;}这道题不是人做的,浮点数。真是看不出来,输出格式更加让人不懂,原创 2015-12-18 18:06:02 · 391 阅读 · 0 评论 -
hdoj acm 1715
#include #include using namespace std;string add(string a,string b){ stringA="0"; A+=a; //必须的 if(a.length() a.swap(b); for ( inti=1;i if(i A[A.le原创 2015-12-18 18:06:05 · 639 阅读 · 0 评论 -
Identity Card hdoj 2629
#include using namespace std;void aa(string a){ strings; int e; e=(int)(a[0]-'0'); e=e*10+(int)(a[1]-'0'); switch(e) { case33:s="Zhejiang"; break;原创 2015-12-18 18:06:07 · 500 阅读 · 0 评论 -
Rightmost Digit hdoj 1061
#include using namespace std;int ee(string s,intn) //计算循环最后的结果{ int a; if(s.length()==1) a=int(s[0]-'0'); else { a=(int)(s[s.length()-2]-'0'); //一般尾数最多是4个或2原创 2015-12-18 18:06:10 · 360 阅读 · 0 评论 -
hdoj acm 1097
http://acm.hdu.edu.cn/showproblem.php?pid=1097#include using namespace std;int main(){ intn,num; inta[9]; while(cin>>n>>num) { n%=10; //关键使n成为个位数字 int temp=n,原创 2015-12-18 18:06:15 · 323 阅读 · 0 评论 -
HDOJ 1004 Let the Balloon Rise
http://acm.hdu.edu.cn/showproblem.php?pid=1004#include using namespace std;int main(){ int n; stringstr[1001]; while(cin>>n,n) { int max=0,maxloc,temp,loc; for(int原创 2015-12-18 18:06:17 · 372 阅读 · 0 评论 -
HDOJ 1051 Wooden Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1051#include #include using namespace std;typedef struct{ intLength; intWeight;}Game;int cmp( const void *a , const void *b ){ Game *c =原创 2015-12-18 18:06:20 · 357 阅读 · 0 评论 -
HDOJ 1236 排名
http://acm.hdu.edu.cn/showproblem.php?pid=1236#include #include #include using namespace std;struct student{ stringname; intsum;};int cmp( const void *a , const void *b ){ struc原创 2015-12-18 18:06:23 · 362 阅读 · 0 评论 -
HDOJ 1753 大明A+B
http://acm.hdu.edu.cn/showproblem.php?pid=1753先将小数的两部分分开,(要考虑到只有整数部分的情况)再分别计算使用addd函数壁一般的字符串大数加法多了一个参数,这个参数可以判断是在给整数部分想加,还是在给小数部分相加,因为小数部分相加的时候,要把位数在后面加“0”保证两个小数部分的位书相同,然后再加,还要考虑小数部分的进位情况,最后输出的时候要把小原创 2015-12-18 18:06:25 · 403 阅读 · 0 评论 -
HDOJ 2037 今年暑假不AC
http://acm.hdu.edu.cn/showproblem.php?pid=2037#include #include using namespace std;typedef struct{ intbegin; intend;}Game;Game aa[101];bool cmp(Game a,Game b){ if(a.end原创 2015-12-18 18:06:27 · 380 阅读 · 0 评论 -
HDOJ 2673 shǎ崽 OrOrOrOrz
http://acm.hdu.edu.cn/showproblem.php?pid=2673#include #include #include using namespace std;int main(){ intn,a[10050]; while(scanf("%d",&n)!=EOF) { for(int i=0;i原创 2015-12-18 18:06:30 · 482 阅读 · 0 评论 -
HDOJ 1040 As Easy As A+B
http://acm.hdu.edu.cn/showproblem.php?pid=1040#include #include using namespace std;int main(){ int T; inta,n[1005]; cin>>T; while(T--) { cin>>a; for(int i=0;原创 2015-12-18 18:06:40 · 415 阅读 · 0 评论 -
HDOJ 1005 Number Sequence
转自..............解题思路:1、序列公式f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod7.很明显这是一道找规律的题目。用到模数的一个性质 (a*b)%m=(a%m * b%m)%m,(a+b)%m=(a%m+b%m)%m由此 f(n)=(A%7*f(n-1)+B%7*f(n-2))%7虽然1原创 2015-12-18 18:06:42 · 506 阅读 · 0 评论 -
HDOJ 1010 Tempter of the Bone
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1010#include #include char map[10][10]; //记住数组不能为7intn,m,t; int di,dj; //门的位置boolescape; //判断是否成功的标志intdir[4][2]={{0,-1},{0,1},{原创 2015-12-18 18:06:45 · 499 阅读 · 0 评论 -
HDOJ 1021 Fibonacci Again
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1021#includeint main () { int n; while(scanf("%d",&n) != EOF) printf("%s\n",(n+2)%4?"no":"yes"); return0;}看起来简单的题,开始的时候用暴力求解TLE原创 2015-12-18 18:06:50 · 520 阅读 · 0 评论 -
HDOJ 1271 整数对
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1271 这个题目的思路,是这样的我们假设数字A是这样的一个数字 a*(10^(k+1)) + b*(10^k) + c 其中 a为任意数字,b为去掉的那一位数字,范围 [0,9] 的整数,c<10^k 。则去掉b后的数字B为a*(10^k) + c ,而A+B的值可以用一下式子表示 (11*a+原创 2015-12-18 18:06:52 · 339 阅读 · 0 评论 -
HDOJ 1722 Cake
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1722题目分析:假设Q>P;先分Q份,取出P份(已分好),再将剩下的(Q-P)份看做一块蛋糕,要分给(Q-P)与P人,一直这样往下分,直到(Q-P)等于1时将蛋糕分为P快就可以,然后将所有的加在一起 #include #include int gcd(int a,int b){ r原创 2015-12-18 18:06:55 · 370 阅读 · 0 评论 -
HDOJ 1350 Robot Motion
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1035这几天学习搜索,只能做一些简单的水题....#include #include char map[12][12];int visit[12][12];int main(){ charp,local; inta,b,c,M,N,sum; while(1)原创 2015-12-18 18:06:57 · 358 阅读 · 0 评论 -
HDOJ 1016 Prime Ring Problem
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1016题解:素数环:由1到n个数构成一个环,其中环内任意2个相邻的数字之和是素数。 比较经典的搜索题,由于n#include #include using namespace std;const int MAXN = 41;bool visit[MAXN];int n,p[MAXN]原创 2015-12-18 18:07:05 · 756 阅读 · 0 评论 -
HDOJ 1012 u Calculate e
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1012注意一下中间数据的保存,和最后结果的输出...#include int main(){ printf("ne\n"); printf("------------\n"); printf("01\n"); printf("12\n"); print原创 2015-12-18 18:07:07 · 504 阅读 · 0 评论 -
HDOJ 1013 Digital Roots
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1013#include #include #include int root(int a){ int t=0; while(a>9) { t+=a; a=(a-a)/10; } if(t+a>9) t=root(t+a);原创 2015-12-18 18:07:10 · 378 阅读 · 0 评论 -
HDOJ 1017 A Mathematical Cur…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1017水题,没有其它巧妙的办法,直接来做就可以,,问题是题目要读清楚,输出格式伤不起......#include int main(){ intnumber,n,m,e,sum,flag=0; scanf("%d",&number); while(number--)原创 2015-12-18 18:07:12 · 1285 阅读 · 0 评论 -
HDOJ 1019 Least Common Multipl…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1019简单题,直接求最小公倍数就可以#include #include int gcd(int a,int b){ return!b?a:gcd(b,a%b);}int lcm(int a,int b){ return a/gcd(a,b)*b;}int main(){原创 2015-12-18 18:07:15 · 552 阅读 · 0 评论 -
HDOJ 2004 成绩转换
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2004记得这是刚刚学习C++时候,学习while循环编的....#include int main(){ int n,k; while(scanf("%d", &n) != EOF) { if(n 100) printf("Score原创 2015-12-18 18:07:17 · 366 阅读 · 0 评论 -
HDOJ 2005 第几天?
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2005只要知道什么是闰年就可以....能被4整除,不能被100整除,但能被400整除。#include int r[12]={31,29,31,30,31,30,31,31,30,31,30,31};int p[12]={31,28,31,30,31,30,31,31,30,31,30,31};原创 2015-12-18 18:07:19 · 378 阅读 · 0 评论 -
HDOJ 2007 平方和与立方和
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2007#include int main(){ intn,m,k,d,temp; while(scanf("%d%d", &n,&m) !=EOF) { k=0; d=0; if(n>m) {原创 2015-12-18 18:07:22 · 298 阅读 · 0 评论 -
HDOJ 2012 素数判定
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2012想想应为要测试多组数据,使用素数表还是比较好点#include #include #define SWAP(A,B) {int T;T=A;A=B;B=T;}bool p[3000];void prime(){ memset(p,false,sizeof(p)); for原创 2015-12-18 18:07:24 · 295 阅读 · 0 评论 -
HDOJ 2013 蟠桃记
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2013简单题,直接找规律.....#include #include int main(){ intn,sum; while(scanf("%d",&n)!=EOF) { sum=1; for(int i=1;i s原创 2015-12-18 18:07:27 · 399 阅读 · 0 评论 -
HDOJ 2014 青年歌手大奖赛_评…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2014#include #include int main(){ int n; floatmax,min,sum,a[105]; while(scanf("%d",&n)!=EOF) { sum=0; for(int i=0;i原创 2015-12-18 18:07:29 · 333 阅读 · 0 评论 -
HDOJ 2016 数据的交换输出
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2016#include #include #define SWAP(A,B) {int T;T=A;A=B;B=T;}int main(){ int n; intmin,local,a[105]; while(scanf("%d",&n),n) {原创 2015-12-18 18:07:31 · 441 阅读 · 0 评论 -
HDOJ 2024 C语言合法标识符
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2024主要判断第一个字母,和中间的字母是否由字母,数字,下划线组成#include #include int main(){ intT,flag; chara,temp; scanf("%d",&T); temp=getchar(); while(T--原创 2015-12-18 18:07:34 · 371 阅读 · 0 评论