首页 2023年ACM部分练习题目答案

2023年ACM部分练习题目答案

举报
开通vip

2023年ACM部分练习题目答案ACM部分练习题目答案ACM部分习题答案:A+BProblemTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):100972AcceptedSubmission(s):33404ProblemDescriptionCalculateA+B.InputEachlinewillcontaintwointegersAandB.Processtoendoffile.OutputForeachca...

2023年ACM部分练习题目答案
ACM部分练习题目答案ACM部分习题答案:A+BProblemTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):100972AcceptedSubmission(s):33404ProblemDescriptionCalculateA+B.InputEachlinewillcontaintwointegersAandB.Processtoendoffile.OutputForeachcase,outputA+Binoneline.SampleInput11SampleOutput2#includeIntmain(){intx,y,s;while(scanf("%d%d",&x,&y)!=EOF){s=x+y;printf("%d\n",s);}return0;}SumProblemTimeLimit:1000/500MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):85964AcceptedSubmission(s):19422ProblemDescriptionHey,welcometoHDOJ(HangzhouDianziUniversityOnlineJudge).Inthisproblem,yourtaskistocalculateSUM(n)=1+2+3+...+n.InputTheinputwillconsistofaseriesofintegersn,oneintegerperline.OutputForeachcase,outputSUM(n)inoneline,followedbyablankline.Youmayassumetheresultwillbeintherangeof32-bitsignedinteger.SampleInput1100SampleOutput15050#includeintmain(){intn;longints;while(scanf("%d",&n)!=EOF){s=0;while(n>0){s=s+n;n--;}printf("%ld\n\n",s);}return0;}A+BProblemIITimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):58216AcceptedSubmission(s):10500ProblemDescriptionIhaveaverysimpleproblemforyou.GiventwointegersAandB,yourjobistocalculatetheSumofA+B.InputThefirstlineoftheinputcontainsanintegerT(1#includeintmain(){charx[1001],y[1001],z[1001];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;i>0i--,j--){m+=x[i-1]-'0'+y[j-1]-'0';z[k++]=m%10+'0';m/=10;}for(;i>0;i--){m+=x[i-1]-'0';z[k++]=m%10+'0';m/=10;}for(;j>0;j--){m+=y[j-1]-'0';z[k++]=m%10+'0';m/=10;}if(m>0)z[k++]=m%10+'0';printf("Case%d:\n%s+%s=",o-n,x,y);for(;k>0;k--)printf("%c",z[k-1]);printf("\n");if(n)printf("\n");}return0;}LettheBalloonRiseTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):24082AcceptedSubmission(s):7343ProblemDescriptionContesttimeagain!Howexciteditistoseeballoonsfloatingaround.Buttotellyouasecret,thejudges'favoritetimeisguessingthemostpopularproblem.Whenthecontestisover,theywillcounttheballoonsofeachcolorandfindtheresult.Thisyear,theydecidetoleavethislovelyjobtoyou.InputInputcontainsmultipletestcases.EachtestcasestartswithanumberN(03pinkorangepinkSampleOutputredpink#include#includevoidmain(){intn,i,j,k,t,a[1001];charh[1001][16];while(scanf("%d",&n)!=EOF){if(n==0)break;for(i=0;ik){k=a[i];t=i;}}printf("%s\n",h[t]);}}ElevatorTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):12849AcceptedSubmission(s):6646ProblemDescriptionThehighestbuildinginourcityhasonlyoneelevator.ArequestlistismadeupwithNpositivenumbers.Thenumbersdenoteatwhichfloorstheelevatorwillstop,inspecifiedorder.Itcosts6secondstomovetheelevatoruponefloor,and4secondstomovedownonefloor.Theelevatorwillstayfor5secondsateachstop.Foragivenrequestlist,youaretocomputethetotaltimespenttofulfilltherequestsonthelist.Theelevatorisonthe0thflooratthebeginninganddoesnothavetoreturntothegroundfloorwhentherequestsarefulfilled.InputTherearemultipletestcases.EachcasecontainsapositiveintegerN,followedbyNpositivenumbers.Allthenumbersintheinputarelessthan100.AtestcasewithN=0denotestheendofinput.Thistestcaseisnottobeprocessed.OutputPrintthetotaltimeonasinglelineforeachtestcase.SampleInput123231SampleOutput1741#includeintmain(){inta,b,n,t;while(scanf("%d",&n)!=EOF&&n){t=0;b=0;t+=n*5;//停的总时间累加起来while(n--){scanf("%d",if(a>b)t+=6*(a-b);//与前次比若上升elseif(aindicatedbyanintegervalueofzero.OutputForeachintegerintheinput,outputitsdigitalrootonaseparatelineoftheoutput.SampleInput2439SampleOutput63#include#includeintmain(){intl,s,i;chara[1000];while(scanf("%s",a)){l=strlen(a);s=0;if(l==1&&(strcmp(a,"0")==0))break;else{for(i=0;i9){l=0;while(s){l+=s%10;s/=10;}s=l;}s=(s%10+s/10);printf("%d\n",s);}}return0;}AsEasyAsA+BTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):12198AcceptedSubmission(s):4870ProblemDescriptionThesedays,Iamthinkingaboutaquestion,howcanIgetaproblemaseasyasA+B?Itisfairlydifficultytodosuchathing.Ofcourse,Igotitaftermanywakingnights.Giveyousomeintegers,yourtaskistosortthesenumberascending(升序).Youshouldknowhoweasytheproblemisnow!Goodluck!inputInputcontainsmultipletestcases.ThefirstlineoftheinputisasingleintegerTwhichisthenumberoftestcases.Ttestcasesfollow.EachtestcasecontainsanintegerN(1intmain(){intn,i;scanf("%d",for(i=0;ia[k+1]){t=a[k];a[k]=a[k+1];a[k+1]=t;}printf("%d",a[0]);for(j=1;j
本文档为【2023年ACM部分练习题目答案】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
个人认证用户
资源共享
暂无简介~
格式:doc
大小:15KB
软件:Word
页数:16
分类:
上传时间:2023-03-20
浏览量:51