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

险啊,1.5s

Posted by deathado at 2008-05-17 18:15:46 on Problem 2602
#include<stdio.h>
main()
{
	long n;
	char num[1000001];
	int i,j;
	int a,b;
	for(i=0;i<1000001;i++)
		num[i]=0;
	scanf("%ld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		num[i]=a+b;
	}
	for(i=n-1;i>=0;i--)
	{
		if(num[i]>=10)
		{
			num[i-1]+=num[i]/10;
			num[i]=num[i]%10;
		}
		num[i]+='0';
	}
	printf("%s\n",num);
}
	
-------------------------------

用字符数组就不会RE,如果用int ,short连本地测试都过不了。

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