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

测了几乎所有的数据,

Posted by qmczcn at 2004-11-24 21:22:09 on Problem 2100
In Reply To:我的程序怎么会wa!!!!!!!!,北大的大牛们看看!!! Posted by:qmczcn at 2004-11-24 21:20:25
> #include <iostream.h>
> #include <stdio.h>
> #include <math.h>
> 
> _int64 n ;
> 
> long  total=0;
> _int64 counter;
> long ans;
> 
> long  a[10000];
> long  dd[10000];
> 
> long  i , j , k ;
> 
> 
> bool could (long d)
> {
> 	_int64  a, b , c;
> 	if  ((6*n) % d !=0) return false;
> 
> 	_int64 k;
> 	k = (6*n) / d;
> 	
> 	a=6; b=(6*d+6);  c=(2*d*d+3*d+1-k);
> 	
> 	if (b*b<4*a*c) return false;
> 
>     ans = long ((-b+sqrt(b*b-4*a*c))/2/a);
> 	if  (a*ans*ans+b*ans+c==0) return true;
> 
> 	return false;
> }
> 
> void out()
> {
> 
> 	printf("%ld\n",total);
> 	for (i=total; i>=1; i--)
> 	{
> 		printf("%ld ",dd[i]);
> 		for (j=1;j<=dd[i]-1; j++) 
> 		{printf("%ld ",a[i]+j);}
> 		printf("%ld\n" , a[i]+dd[i]);
> 	}
> }
> 
> void work()
> {
> 	long d;
> 	_int64 k;
> 	counter=0;
> 	total=0;
> 	for (d=1; (counter<=n-d*d) ; d++)
> 	{
> 		if (could(d))
> 		{
> 			total++ ;
> 			a[total]=ans;
> 			dd[total]=d;
> 		}
> 		k=d;
> 		counter=counter+k*k;
> 	}
> 
>    
>     //printf("%d\n",d);
>   // if (total>2)	
> 	   out();
> }
> 
> int main()
> {
> 		scanf("%I64d",&n);
> //	for (n=800000; n<=1000000; n++)
> 	{work();}
> 
> 		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