Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- int gcd(int a,int b){
- while(b) b ^= a ^= b ^= a %= b;
- return a;
- }
- int numbers[50];
- int main() {
- int num,i,cnt,j,k,pairs;
- while (scanf("%d", &num)==1) {
- if (num==0) return 0;
- for (i=0;i<num;i++) scanf("%d", &numbers[i]);
- cnt=0;
- pairs=num*(num-1)/2;
- for (i=0;i<num;i++) {
- for (j=i+1;j<num;j++) {
- if (gcd(numbers[i],numbers[j])==1) cnt++;
- }
- }
- if (cnt>0) {
- double ans = sqrt((6*pairs*1.00)/cnt);
- printf("%.6lf\n",ans);
- }
- else printf("No estimate for this data set.\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement