Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Accepted
- // Time : 0.076
- #include <iostream>
- #include <cstdio>
- #include <cmath>
- #include <algorithm>
- #define N 51
- using namespace std;
- int ar[N],l=0;
- int gcd (int a , int b)
- {
- //int r=1;
- if (a>b)
- {
- swap(a,b);
- }
- int r=1;
- while (r!=0)
- {
- r = b%a;
- b = a;
- a = r;
- }
- return b;
- }
- int main()
- {
- int cnt;
- int n;
- while (cin >> n)
- {
- if (n==0)
- {
- break;
- }
- for (int i=0;i<n;i++)
- {
- cin >> ar[i];
- }
- cnt = 0;
- int sonn = n*(n-1)/2; // Set of Natural Number = (n*(n-1))/2;
- for (int i=0;i<n-1;i++)
- {
- for (int j=i+1;j<n;j++)
- {
- if (gcd(ar[i],ar[j]) == 1)
- {
- //printf("(%d %d) ",ar[i],ar[j]);
- cnt++;
- }
- }
- }
- if (cnt == 0)
- {
- printf ("No estimate for this data set.\n");
- }
- else
- {
- printf("%.6lf\n",sqrt((1.0*6.0*sonn)/cnt));
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement