资源描述:
《整理出acm所有题目与答案解析》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、WORD格式可编辑1000A+BProblemProblemDescriptionCalculateA+B.InputEachlinewillcontaintwointegersAandB.Processtoendoffile. OutputForeachcase,outputA+Binoneline. SampleInput11 SampleOutput2 AuthorHDOJ代码:#includeintmain(){inta,b;while(scanf("%d%d",&a,&b
2、)!=EOF)printf("%d",a+b);}1001SumProblemProblemDescriptionHey,welcometoHDOJ(HangzhouDianziUniversityOnlineJudge).Inthisproblem,yourtaskistocalculateSUM(n)=1+2+3+...+n. 专业技术资料分享WORD格式可编辑InputTheinputwillconsistofaseriesofintegersn,oneintegerperline. Ou
3、tputForeachcase,outputSUM(n)inoneline,followedbyablankline.Youmayassumetheresultwillbeintherangeof32-bitsignedinteger. SampleInput1100 SampleOutput15050 AuthorDOOMIII解答:#includemain(){intn,i,sum;sum=0;while((scanf("%d",&n)!=-1)){sum=0;for(i=0;
4、i<=n;i++)sum+=i;printf("%d",sum);}}专业技术资料分享WORD格式可编辑1002A+BProblemIIProblemDescriptionIhaveaverysimpleproblemforyou.GiventwointegersAandB,yourjobistocalculatetheSumofA+B. InputThefirstlineoftheinputcontainsanintegerT(1<=T<=20)whichmeansthenumberoft
5、estcases.ThenTlinesfollow,eachlineconsistsoftwopositiveintegers,AandB.Noticethattheintegersareverylarge,thatmeansyoushouldnotprocessthembyusing32-bitinteger.Youmayassumethelengthofeachintegerwillnotexceed1000. OutputForeachtestcase,youshouldoutputtwoli
6、nes.Thefirstlineis"Case#:",#meansthenumberofthetestcase.Thesecondlineistheanequation"A+B=Sum",SummeanstheresultofA+B.Notetherearesomespacesinttheequation.Outputablanklinebetweentwotestcases. SampleInput212112233445566778899998877665544332211 SampleOutp
7、utCase1:1+2=3Case2:112233445566778899+998877665544332211=1111111111111111110 AuthorIgnatius.L 代码:#include#includeintmain(){charstr1[1001],str2[1001];intt,i,len_str1,len_str2,len_max,num=1,k;scanf("%d",&t);getchar();while(t--){专业技术资料分
8、享WORD格式可编辑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[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';i