资源描述:
《部分ACM题目及答案.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.1001SumProblem21089A+BforInput-OutputPractice(I)41090A+BforInput-OutputPractice(II)61091A+BforInput-OutputPractice(III)81092A+BforInput-OutputPractice(IV)91093A+BforInput-OutputPractice(V)111094A+BforInput-OutputPractice(VI)121095A+BforInput-OutputPractice(VII)131096A+BforInput-Out
2、putPractice(VIII)142000ASCII码排序162001计算两点间的距离172002计算球体积192003求绝对值202004成绩转换212005第几天?222006求奇数的乘积242007平方和与立方和262008数值统计272009求数列的和282010水仙花数292011多项式求和312012素数判定332014青年歌手大奖赛_评委会打分342015偶数求和362016数据的交换输出382017字符串统计402019数列有序!412020绝对值排序432021发工资咯:)452033人见人爱A+B462039三角形482040亲和数49
3、..1001SumProblemProblemDescriptionHey,welcometoHDOJ(HangzhouDianziUniversityOnlineJudge).Inthisproblem,yourtaskistocalculateSUM(n)=1+2+3+...+n. InputTheinputwillconsistofaseriesofintegersn,oneintegerperline. OutputForeachcase,outputSUM(n)inoneline,followedbyablankline.Youmayassumeth
4、eresultwillbeintherangeof32-bitsignedinteger. SampleInput1100 SampleOutput15050 Author..DOOMIII解答:#includemain(){intn,i,sum;sum=0;while((scanf("%d",&n)!=-1)){sum=0;for(i=0;i<=n;i++)sum+=i;printf("%d",sum);}}..1089A+BforInput-OutputPractice(I)ProblemDescriptionYourtaskis
5、toCalculatea+b.Tooeasy?!Ofcourse!Ispeciallydesignedtheproblemforacmbeginners.Youmusthavefoundthatsomeproblemshavethesametitleswiththisone,yes,alltheseproblemsweredesignedforthesameaim. InputTheinputwillconsistofaseriesofpairsofintegersaandb,separatedbyaspace,onepairofintegersperline
6、. OutputForeachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput. SampleInput151020 SampleOutput630 Authorlcy ..RecommendJGShining解答:#includemain(){inta,b;while(scanf("%d%d",&a,&b)!=EOF)printf("%d",a+b);}..1090A+BforInp
7、ut-OutputPractice(II)ProblemDescriptionYourtaskistoCalculatea+b. InputInputcontainsanintegerNinthefirstline,andthenNlinesfollow.Eachlineconsistsofapairofintegersaandb,separatedbyaspace,onepairofintegersperline. OutputForeachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneli
8、ne,andwithonelineof