// UVa 412 - Pi #include <iostream> #include <stdio.h> #include <math.h> using namespace std; int gcd(int a, int b) { if (a < b) return gcd(b, a); if (b == 0) return a; else return gcd(b, a % b); } int main() { int n, a[51]; cin >> n; while (n) { int c = 0; for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = 0; j < i; j++) { int g = gcd(a[i], a[j]); if (g == 1) c++; } } if (c == 0) cout << "No estimate for this data set." << endl; else { double s = sqrt(6.0 * n * (n - 1) / 2 / c); printf("%.6f\n", s); } cin >> n; } }
No comments:
Post a Comment