杭电ACM部分题答案.doc

杭电ACM部分题答案.doc

ID:51768918

大小:45.50 KB

页数:8页

时间:2020-03-15

杭电ACM部分题答案.doc_第1页
杭电ACM部分题答案.doc_第2页
杭电ACM部分题答案.doc_第3页
杭电ACM部分题答案.doc_第4页
杭电ACM部分题答案.doc_第5页
资源描述:

《杭电ACM部分题答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、1000A+BProblemTimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):158161    AcceptedSubmission(s):50186ProblemDescriptionCalculateA+B. InputEachlinewillcontaintwointegersAandB.Processtoendoffile. OutputForeachcase,outputA+Binoneline

2、. SampleInput11 SampleOutput2 AuthorHDOJ Statistic 

3、 Submit 

4、 Discuss

5、Note#includeintmain(){inta,b;while(scanf("%d%d",&a,&b)!=EOF)printf("%d",a+b);}1002A+BProblemIITimeLimit:2000/1000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):84367

6、    AcceptedSubmission(s):15966ProblemDescriptionIhaveaverysimpleproblemforyou.GiventwointegersAandB,yourjobistocalculatetheSumofA+B. InputThefirstlineoftheinputcontainsanintegerT(1<=T<=20)whichmeansthenumberoftestcases.ThenTlinesfollow,eachlineconsistsoftwopositiveintegers

7、,AandB.Noticethattheintegersareverylarge,thatmeansyoushouldnotprocessthembyusing32-bitinteger.Youmayassumethelengthofeachintegerwillnotexceed1000. OutputForeachtestcase,youshouldoutputtwolines.Thefirstlineis"Case#:",#meansthenumberofthetestcase.Thesecondlineistheanequation"

8、A+B=Sum",SummeanstheresultofA+B.Notetherearesomespacesinttheequation.Outputablanklinebetweentwotestcases. SampleInput212112233445566778899998877665544332211 SampleOutputCase1:1+2=3Case2:112233445566778899+998877665544332211=1111111111111111110 AuthorIgnatius.L Statistic 

9、 S

10、ubmit 

11、 Discuss

12、Note#include#includeintmain(){charstr1[1001],str2[1001];intt,i,len_str1,len_str2,len_max,num=1,k;scanf("%d",&t);getchar();while(t--){inta[1001]={0},b[1001]={0},c[1001]={0};scanf("%s",str1);len_str1=strlen(str1);for(i=0;i<=len_str1-1;++i)a[

13、i]=str1[len_str1-1-i]-'0';scanf("%s",str2);len_str2=strlen(str2);for(i=0;i<=len_str2-1;++i)b[i]=str2[len_str2-1-i]-'0';if(len_str1>len_str2)len_max=len_str1;elselen_max=len_str2;k=0;for(i=0;i<=len_max-1;++i){c[i]=(a[i]+b[i]+k)%10;k=(a[i]+b[i]+k)/10;}if(k!=0)c[len_max]=1;pri

14、ntf("Case%d:",num);num++;printf("%s+%s=",str1,str2);if(c[len_max]==1)printf("1")

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。