整理出acm所有題目及答案

整理出acm所有題目及答案

ID:22033107

大小:1.70 MB

頁數(shù):208頁

時間:2018-10-26

整理出acm所有題目及答案_第1頁
整理出acm所有題目及答案_第2頁
整理出acm所有題目及答案_第3頁
整理出acm所有題目及答案_第4頁
整理出acm所有題目及答案_第5頁
資源描述:

《整理出acm所有題目及答案》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫

1、1000A+BProblemProblemDescriptionCalculateA+B.InputEachlinewillcontaintwointegersAandB.Processtoendoffile.?OutputForeachcase,outputA+Binoneline.?SampleInput11?SampleOutput2?AuthorHDOJ代碼:#includeintmain(){inta,b;while(scanf("%d%d",&a,&b)!=EOF)printf("%d",

2、a+b);}1001SumProblemProblemDescriptionHey,welcometoHDOJ(HangzhouDianziUniversityOnlineJudge).Inthisproblem,yourtaskistocalculateSUM(n)=1+2+3+...+n.?208InputTheinputwillconsistofaseriesofintegersn,oneintegerperline.?OutputForeachcase,outputSUM(n)inoneline,followedb

3、yablankline.Youmayassumetheresultwillbeintherangeof32-bitsignedinteger.?SampleInput1100?SampleOutput15050?AuthorDOOMIII解答:#includemain(){intn,i,sum;sum=0;while((scanf("%d",&n)!=-1)){sum=0;for(i=0;i<=n;i++)sum+=i;printf("%d",sum);}}2081002A+BProblemIIP

4、roblemDescriptionIhaveaverysimpleproblemforyou.GiventwointegersAandB,yourjobistocalculatetheSumofA+B.?InputThefirstlineoftheinputcontainsanintegerT(1<=T<=20)whichmeansthenumberoftestcases.ThenTlinesfollow,eachlineconsistsoftwopositiveintegers,AandB.Noticethatthein

5、tegersareverylarge,thatmeansyoushouldnotprocessthembyusing32-bitinteger.Youmayassumethelengthofeachintegerwillnotexceed1000.?OutputForeachtestcase,youshouldoutputtwolines.Thefirstlineis"Case#:",#meansthenumberofthetestcase.Thesecondlineistheanequation"A+B=Sum",Sum

6、meanstheresultofA+B.Notetherearesomespacesinttheequation.Outputablanklinebetweentwotestcases.?SampleInput212112233445566778899998877665544332211?SampleOutputCase1:1+2=3Case2:112233445566778899+998877665544332211=1111111111111111110?AuthorIgnatius.L?代碼:#include

7、io.h>#includeintmain(){charstr1[1001],str2[1001];intt,i,len_str1,len_str2,len_max,num=1,k;scanf("%d",&t);getchar();while(t--){208inta[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-

8、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=le

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文

此文檔下載收益歸作者所有

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學(xué)公式或PPT動畫的文件,查看預(yù)覽時可能會顯示錯亂或異常,文件下載后無此問題,請放心下載。
2. 本文檔由用戶上傳,版權(quán)歸屬用戶,天天文庫負責(zé)整理代發(fā)布。如果您對本文檔版權(quán)有爭議請及時聯(lián)系客服。
3. 下載前請仔細閱讀文檔內(nèi)容,確認文檔內(nèi)容符合您的需求后進行下載,若出現(xiàn)內(nèi)容與標題不符可向本站投訴處理。
4. 下載文檔時可能由于網(wǎng)絡(luò)波動等原因無法下載或下載錯誤,付費完成后未能成功下載的用戶請聯(lián)系客服處理。