Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
输入的问题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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator