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

大家帮忙看一下第几个数据出的错?thanks!

Posted by zhuqinglu at 2004-05-12 13:20:25 on Problem 1019
#include<stdio.h>
#include<math.h>
void main()
{
	int i,num,ce;
	long double t;
	long n,a[10];
	scanf("%d",&num);
	for(i=0;i<num;i++)
		scanf("%ld",&a[i]);
	for(i=0;i<num;i++)
	{
		ce=1;
		t=(long double)a[i]/8+1.0/64;
		n=(long)(sqrt(t)*4-0.5);
		if(n%2==0) ce=0;
		if(ce==1)
		{
			if(a[i]==n*((n+1)/2))
				printf("%ld\n",n);
			else
				printf("%ld\n",a[i]-n*((n+1)/2));
		}
		else if(ce==0)
		{
			if(a[i]==n/2*(n+1))
				printf("%ld\n",n);
			else
				printf("%ld\n",a[i]-n/2*(n+1));
		}
	}
}
提交时说wrong answer!到底哪个出的错啊,我实在找不出来。希望高手给找找,或者发一个已经测试通过的程序,感激啊!!!

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