资源预览内容
第1页 / 共208页
第2页 / 共208页
第3页 / 共208页
第4页 / 共208页
第5页 / 共208页
第6页 / 共208页
第7页 / 共208页
第8页 / 共208页
第9页 / 共208页
第10页 / 共208页
亲,该文档总共208页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
.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 ProblemProblem 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 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 problem 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 large, 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 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 #include 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 = strlen(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) mod 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.OutputFor 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-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
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号