杭电ACM部分题答案.doc

上传人:xt****7 文档编号:126187298 上传时间:2020-03-23 格式:DOC 页数:8 大小:45.50KB
返回 下载 相关 举报
杭电ACM部分题答案.doc_第1页
第1页 / 共8页
杭电ACM部分题答案.doc_第2页
第2页 / 共8页
杭电ACM部分题答案.doc_第3页
第3页 / 共8页
杭电ACM部分题答案.doc_第4页
第4页 / 共8页
杭电ACM部分题答案.doc_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《杭电ACM部分题答案.doc》由会员分享,可在线阅读,更多相关《杭电ACM部分题答案.doc(8页珍藏版)》请在金锄头文库上搜索。

1、1000A + B ProblemTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 158161Accepted Submission(s): 50186Problem 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

2、 line.Sample Input1 1Sample Output2AuthorHDOJStatistic|Submit|Discuss | Note#includeint main() int a,b; while(scanf(%d %d,&a,&b)!=EOF) printf(%dn,a+b);1002A + B Problem IITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 84367Accepted Submission(s):

3、15966Problem 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

4、 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 s

5、econd 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 = 1111111

6、111111111110AuthorIgnatius.LStatistic|Submit|Discuss | Note#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_st

7、r1 - 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;1005Number SequenceTime Limit: 2000/1000 MS (Java/Others)Memor

8、y Limit: 65536/32768 K (Java/Others)Total Submission(s): 44346Accepted Submission(s): 9722Problem 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 mult

9、iple 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

10、Output25AuthorCHEN, ShunbaoSourceZJCPC2004 RecommendJGShiningStatistic|Submit|Discuss | Note#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(

11、%dn,fn); else printf(1n); return 0;1008ElevatorTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17764Accepted Submission(s): 9490Problem 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,

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

当前位置:首页 > 中学教育 > 试题/考题

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