-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path412.c
32 lines (30 loc) · 772 Bytes
/
412.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*http://uva.onlinejudge.org/external/4/412.html*/
#include <stdio.h>
#include <math.h>
/*greatest common divisor*/
int gcd(int a, int b)
{
if (0==b) return a;
return gcd(b, a%b);
}
int main(int argc, char **argv)
{
int i, j, n, count, data[64];
while (scanf("%d\n", &n) != EOF) {
if (n==0 || n>50) break;
count = 0;
for (i=0;i<n;i++) scanf("%d\n", &data[i]);
for (i=0;i<n;i++) {
for (j=i+1;j<n;j++) {
if (1 == gcd(data[i], data[j])) count++;
}
}
if (0==count)
printf("No estimate for this data set.\n");
else {
double v = n*(n-1)/2; /*c(n,2)*/
printf("%.6f\n", sqrt(6.0*v/(double)count));
}
}
return 0;
}