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

Re:测试数据错了。。

Posted by x_zhou at 2010-08-19 13:26:16 on Problem 1503
In Reply To:测试数据错了。。 Posted by:x_zhou at 2010-08-19 13:16:41
> 9999
> 9
> 我的程序算出结果错了 结果ac了
> 更改程序结果对了 提交后居然wa
> 。。。。
#include<stdio.h>
#include<string.h>
char str[101];
int main()
{
	int i,j,ans[201];

	memset(ans,0,sizeof(ans));
	while(gets(str),strcmp(str,"0"))
	{
		j=0;
		for(i=strlen(str)-1;i>=0;i--)
		{
			ans[j++]+=(str[i]-'0');
			if(ans[j-1]>=10)
			{
				ans[j-1]-=10;
				ans[j]++;
			}
		}
	}
	/*for(i=0;i<201;i++)//加上此段程序就会wa 但别的结果确实正确
		if(ans[i]>=10)
		{
			ans[i+1]++;
			ans[i]-=10;
		}*/
	int flag=0;
	for(i=200;i>=0;i--)
		if(flag)
			printf("%d",ans[i]);
		else if(ans[i])
		{
			flag=1;
			printf("%d",ans[i]);
		}
	if(!flag)
		printf("0");
	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