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

O(n^2logn),必挂了

Posted by frkstyc at 2005-07-14 13:44:33 on Problem 2478
In Reply To:为什么测试时没有错误,提交时总有错呢? Posted by:mach at 2005-07-14 13:40:45
> #include <stdio.h>
> long gcd(long a,long b)
> {long r;
>  while(b)
>  {r=a%b;
>   a=b;
>   b=r;
>  }
>  return a;
> }
> int main()
> {long n,i,j,cal;
>  long temp;
>  while(n)
>  {scanf("%ld",&n);
>   cal=0;
>   for(i=1;i<n;i++)
> 	for(j=i+1;j<=n;j++)
> 	{temp=gcd(i,j);
> 	 if(temp==1) cal++;
> 	}
>   if(n==0) break;
>   if(n) printf("%ld\n",cal);
>   
>  }
>   return 1;
> }

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