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 |
为什么测试时没有错误,提交时总有错呢?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator