Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

喵了个咪的 实验证明数组至少开到107才能AC

Posted by jndx20111221395 at 2012-03-28 00:51:26 on Problem 1503
#include<stdio.h>
#include<string.h>
int main()
{
	char a[107],sum[108];int i,j,len;
	for(i=0;i<107;i++)sum[i]=0;
	while(1)
	{
		scanf("%s",a);
		j=(len=strlen(a))-1;
		if(len==1&&*a==48)break;
		for(i=107;i>107-len;i--)
			sum[i]+=a[j--]-48;
		for(i=107;i>107-len;i--)
			sum[i-1]+=sum[i]/10,sum[i]=sum[i]%10;
		for(i=0;i<len;i++)a[i]=0;
	}
	for(i=107;i>1;i--)
		sum[i-1]+=sum[i]/10,sum[i]=sum[i]%10;
	for(i=0;i<108;i++)
		if(sum[i]!=0)break;
	if(i==108)putchar('0');
	while(i<108)
		putchar(sum[i++]+48);
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator