整理出ACM所有题目及内容答案

上传人:不*** 文档编号:89202881 上传时间:2019-05-21 格式:DOC 页数:208 大小:959KB
返回 下载 相关 举报
整理出ACM所有题目及内容答案_第1页
第1页 / 共208页
整理出ACM所有题目及内容答案_第2页
第2页 / 共208页
整理出ACM所有题目及内容答案_第3页
第3页 / 共208页
整理出ACM所有题目及内容答案_第4页
第4页 / 共208页
整理出ACM所有题目及内容答案_第5页
第5页 / 共208页
点击查看更多>>
资源描述

《整理出ACM所有题目及内容答案》由会员分享,可在线阅读,更多相关《整理出ACM所有题目及内容答案(208页珍藏版)》请在金锄头文库上搜索。

1、.1000 A + B ProblemProblem DescriptionCalculate A + B.InputEach line will contain two integers A and B. Process to end of file.OutputFor each case, output A + B in one line.Sample Input1 1Sample Output2AuthorHDOJ代码:#includeint main() int a,b; while(scanf(%d %d,&a,&b)!=EOF) printf(%dn,a+b);1001 Sum P

2、roblemProblem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + . + n.InputThe input will consist of a series of integers n, one integer per line.OutputFor each case, output SUM(n) in one line, followed by a blank

3、 line. You may assume the result will be in the range of 32-bit signed integer.Sample Input1100Sample Output15050AuthorDOOM III解答:#includemain() int n,i,sum; sum=0; while(scanf(%d,&n)!=-1) sum=0; for(i=0;i=n;i+) sum+=i; printf(%dnn,sum); 1002 A + B Problem IIProblem DescriptionI have a very simple p

4、roblem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1=T=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very larg

5、e, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.OutputFor each test case, you should output two lines. The first line is Case #:, # means the number of the test case. The second line is the an equation A + B = Sum, Sum

6、 means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.Sample Input21 2112233445566778899 998877665544332211Sample OutputCase 1:1 + 2 = 3Case 2:112233445566778899 + 998877665544332211 = 1111111111111111110AuthorIgnatius.L代码:#include #inclu

7、de int main() char str11001, str21001; int t, i, len_str1, len_str2, len_max, num = 1, k; scanf(%d, &t); getchar(); while(t-) int a1001 = 0, b1001 = 0, c1001 = 0; scanf(%s, str1); len_str1 = strlen(str1); for(i = 0; i = len_str1 - 1; +i) ai = str1len_str1 - 1 - i - 0; scanf(%s,str2); len_str2 = strl

8、en(str2); for(i = 0; i len_str2) len_max = len_str1; else len_max = len_str2; k = 0; for(i = 0; i = 0; -i) printf(%d, ci); printf(n); if(t = 1) printf(n); return 0;1005 Number SequenceProblem DescriptionA number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2) m

9、od 7.Given A, B, and n, you are to calculate the value of f(n).InputThe input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single line (1 = A, B = 1000, 1 = n = 100,000,000). Three zeros signal the end of input and this test case is not to be processed.OutputFo

10、r each test case, print the value of f(n) on a single line.Sample Input1 1 31 2 100 0 0Sample Output25AuthorCHEN, ShunbaoSourceZJCPC2004 RecommendJGShining代码:#includeint f200;int main() int a,b,n,i; while(scanf(%d%d%d,&a,&b,&n)&a&b&n) if(n=3) f1=1;f2=1; for(i=3;i=200;i+) fi=(a*fi-1+b*fi-2)%7; if(fi-

11、1=1&fi=1) break; i-=2; n=n%i; if(n=0) printf(%dn,fi); else printf(%dn,fn); else printf(1n); return 0;1008 ElevatorProblem DescriptionThe highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.For a given request list, you a

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 资格认证/考试 > 其它考试类文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号