Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

又一个大水

Posted by KatrineYang at 2016-10-24 23:03:57 on Problem 1491
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;

int GCD(int a, int b){
	if(a==0) return b;
	if(b==0) return a;
	if(a>b) return GCD(b, a%b);
	return GCD(a, b%a);
}

int main() {
	while(1){
		int n;
		scanf("%d", &n);
		if(!n) return 0;
		int a[500];
		for(int i = 0; i < n; i++){
			scanf("%d", &a[i]);
		}
		int T = 0;
		for(int i = 0; i < n-1; i++){
			for(int j = i+1; j < n; j++){
				if(GCD(a[i], a[j]) == 1) T++;
			}
		}
		if(!T){
			printf("No estimate for this data set.\n");
		}
		else{
			printf("%.6lf\n", sqrt(3*n*(n-1)/(T*1.0)));
		}
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator