ACM部分练习题目答案.docx
《ACM部分练习题目答案.docx》由会员分享,可在线阅读,更多相关《ACM部分练习题目答案.docx(16页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、ACM部分练习题目答案ACM部分习题答案:A+BProblemTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):100972AcceptedSubmission(s):33404ProblemDescriptionCalculateA+B.InputEachlinewillcontaintwointegersAandB.Processtoendoffile.OutputForeachcase,outputA+Binoneline.SampleInput11Sampl
2、eOutput2#includeIntmain()intx,y,s;while(scanf(%d%d,&x,&y)!=EOF)s=x+y;printf(%dn,s);return0;SumProblemTimeLimit:1000/500MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):85964AcceptedSubmission(s):19422ProblemDescriptionHey,welcometoHDOJ(HangzhouDianziUniversityOnlineJudge).Inthi
3、sproblem,yourtaskistocalculateSUM(n)=1+2+3+.+n.InputTheinputwillconsistofaseriesofintegersn,oneintegerperline.OutputForeachcase,outputSUM(n)inoneline,followedbyablankline.Youmayassumetheresultwillbeintherangeof32-bitsignedinteger.SampleInput1100SampleOutput15050#includeintmain()intn;longints;while(s
4、canf(%d,&n)!=EOF)s=0;while(n0)s=s+n;n-;printf(%ldnn,s);return0;A+BProblemIITimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):58216AcceptedSubmission(s):10500ProblemDescriptionIhaveaverysimpleproblemforyou.GiventwointegersAandB,yourjobistocalculatetheSumofA+B.I
5、nputThefirstlineoftheinputcontainsanintegerT(1#includeintmain()charx1001,y1001,z1001;intn,i,j,k,m,o;scanf(%d,o=n;while(n-)scanf(%s%s,x,y);i=strlen(x);j=strlen(y);for(k=0,m=0;i0i-,j-)m+=xi-1-0+yj-1-0;zk+=m%10+0;m/=10;for(;i0;i-)m+=xi-1-0;zk+=m%10+0;m/=10;for(;j0;j-)m+=yj-1-0;zk+=m%10+0;m/=10;if(m0)zk
6、+=m%10+0;printf(Case%d:n%s+%s=,o-n,x,y);for(;k0;k-)printf(%c,zk-1);printf(n);if(n)printf(n);return0;LettheBalloonRiseTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):24082AcceptedSubmission(s):7343ProblemDescriptionContesttimeagain!Howexciteditistoseeballoons
7、floatingaround.Buttotellyouasecret,thejudgesfavoritetimeisguessingthemostpopularproblem.Whenthecontestisover,theywillcounttheballoonsofeachcolorandfindtheresult.Thisyear,theydecidetoleavethislovelyjobtoyou.InputInputcontainsmultipletestcases.EachtestcasestartswithanumberN(03pinkorangepinkSampleOutpu
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ACM 部分 练习 题目 答案
限制150内