javaee论坛

普通会员

225648

帖子

334

回复

348

积分

楼主
发表于 2019-10-30 11:14:09 | 查看: 373 | 回复: 0

 

Ihaveaverysimpleproblemforyou.GiventwointegersAandB,yourjobistocalculatetheSumofA+B. 

Input

ThefirstlineoftheinputcontainsanintegerT(1<=T<=20)whichmeansthenumberoftestcases.ThenTlinesfollow,eachlineconsistsoftwopositiveintegers,AandB.Noticethattheintegersareverylarge,thatmeansyoushouldnotprocessthembyusing32-bitinteger.Youmayassumethelengthofeachintegerwillnotexceed1000. 

Output

Foreachtestcase,youshouldoutputtwolines.Thefirstlineis"Case#:",#meansthenumberofthetestcase.Thesecondlineistheanequation"A+B=Sum",SummeanstheresultofA+B.Notetherearesomespacesinttheequation.Outputablanklinebetweentwotestcases. 

SampleInput

212112233445566778899998877665544332211

SampleOutput

Case1:1+2=3Case2:112233445566778899+998877665544332211=1111111111111111110

代码:

importjava.io.BufferedInputStream;importjava.math.BigInteger;importjava.util.Scanner;publicclassMain{publicstaticvoidmain(String[]args){//TODO自动生成的方法存根Scannerstr=newScanner(System.in);intT;T=str.nextInt();inti=1;for(i=1;i<=T;i++){BigIntegera=str.nextBigInteger();BigIntegerb=str.nextBigInteger();System.out.println("Case"+i+":");System.out.println(a+"+"+b+"="+a.add(b));if(i<T){System.out.println("");}}}}

 


您需要登录后才可以回帖 登录 | 立即注册

触屏版| 电脑版

技术支持 历史网 V2.0 © 2016-2017