1 #include<iostream> 2 #include<cmath> 3 #include<iomanip> 4 #define MAXN 50 5 using namespace std; 6 7 int _m[MAXN]; 8 int gcd(int a,int b); 9 int main() 10 { 11 //freopen("acm.acm","r",stdin); 12 int n; 13 int i; 14 int j; 15 double sum_all; 16 double sum; 17 while(cin>>n,n) 18 { 19 sum = 0; 20 sum_all = 0; 21 for(i = 0; i < n; ++ i) 22 { 23 cin>>_m[i]; 24 } 25 for(i = 0; i < n; ++ i) 26 { 27 for(j = i+1; j < n; ++ j) 28 { 29 if(gcd(_m[i],_m[j]) == 1) 30 { 31 ++ sum; 32 } 33 ++ sum_all; 34 } 35 } 36 if(sum == 0) 37 { 38 cout<<"No estimate for this data set."<<endl; 39 continue; 40 } 41 42 cout<<setiosflags(ios::fixed)<<setprecision(6)<<sqrt(((sum_all*6.0)/sum))<<endl; 43 } 44 45 } 46 47 int gcd(int a,int b) 48 { 49 if(b == 0) 50 return a; 51 return gcd(b,a%b); 52 }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com