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 |
why system error???include<iostream.h> #include<math.h> #include<iomanip.h> int answer[32768][32767]; int gcd(int aa,int bb) { if(bb==0) { answer[aa][bb]=aa; } else { if(answer[bb][aa%bb]!=0) answer[aa][bb]=answer[bb][aa%bb]; else { answer[bb][aa%bb]=gcd(bb,aa%bb); answer[aa][bb]=answer[bb][aa%bb]; } } return answer[aa][bb]; } void main() { int n,i,j; double m; int a[51]; while(cin>>n) { if(n==0) return; else { int num=0; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=n;i++) for(j=i+1;j<=n;j++) { if(a[i]>a[j]) { if(gcd(a[i],a[j])==1) num++; } if(a[i]<a[j]) { if(gcd(a[j],a[i])==1) num++; } if((a[i]==1)&&(a[j]==1)) num++; } if(num==0) { cout<<"No estimate for this data set."<<endl; } else { m=sqrt(3.0*n*(n-1)/num); cout<<setiosflags(ios::fixed); cout<<m<<setprecision(6)<<endl; } } } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator