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 xfxyjwf at 2005-07-14 13:49:07 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;scanf("%ld",&n);
 while(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);
  scanf("%ld",&n);
 }
  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