字典翻译 问答 小学 英语 【各位大虾帮我看一看这道程序哪里错了,zojacm1292integerinquiryOneofthefirstusersofBIT'snewsupercomputerwasChipDiller.Heextendedhisexplorationofpowersof3togofrom0to333andheexploredtakingvarioussumsofth】
问题标题:
【各位大虾帮我看一看这道程序哪里错了,zojacm1292integerinquiryOneofthefirstusersofBIT'snewsupercomputerwasChipDiller.Heextendedhisexplorationofpowersof3togofrom0to333andheexploredtakingvarioussumsofth】
问题描述:

各位大虾帮我看一看这道程序哪里错了,zojacm1292integerinquiry

OneofthefirstusersofBIT'snewsupercomputerwasChipDiller.Heextendedhisexplorationofpowersof3togofrom0to333andheexploredtakingvarioussumsofthosenumbers.

``Thissupercomputerisgreat,''remarkedChip.``IonlywishTimothywereheretoseetheseresults.''(Chipmovedtoanewapartment,onceonebecameavailableonthethirdflooroftheLemonSkyapartmentsonThirdStreet.)

Input

Theinputwillconsistofatmost100linesoftext,eachofwhichcontainsasingleVeryLongInteger.EachVeryLongIntegerwillbe100orfewercharactersinlength,andwillonlycontaindigits(noVeryLongIntegerwillbenegative).

Thefinalinputlinewillcontainasinglezeroonalinebyitself.

Output

YourprogramshouldoutputthesumoftheVeryLongIntegersgivenintheinput.

Thisproblemcontainsmultipletestcases!

ThefirstlineofamultipleinputisanintegerN,thenablanklinefollowedbyNinputblocks.Eachinputblockisintheformatindicatedintheproblemdescription.Thereisablanklinebetweeninputblocks.

TheoutputformatconsistsofNoutputblocks.Thereisablanklinebetweenoutputblocks.

SampleInput

1

123456789012345678901234567890

123456789012345678901234567890

123456789012345678901234567890

SampleOutput

370370367037037036703703703670

#include

#include

intmain()

{

chara[200]={0};

inti,m,n,k,j,sum[200]={0};

scanf("%d",&k);

while(k--)

{

n=0;

while(scanf("%s",a)&&a[0]!='0')

{

m=strlen(a);

n=n>m?n:m;

for(i=0;i=0)

sum[i]+=(a[m-i-1]-'0');

sum[i+1]+=sum[i]/10;

sum[i]%=10;

}

if(sum[n]!=0)

n++;

}

for(i=n-1;i>=0;i--)

printf("%d",sum[i]);

if(k)

printf("nn");

memset(sum,0,sizeof(sum));

}

return0;

}

沈海平回答:
  这种题一般比较简单但因为有特殊情况AC率比较低特殊情况input210002030output15----------1.题目中说Thefinalinputlinewillcontaina“single”zeroonalinebyitself.所以00不算“single”zero只能算是...
点击显示
英语推荐
热门英语推荐
  • 语文
  • 数学
  • 英语
  • 科学
  • 作文