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 wangyang788544 at 2005-09-02 21:41:43 on Problem 1491
#include<string>
#include<stdio.h>
#include<cmath>
#include<iostream>
using namespace std;
bool haha(int a,int b)
{
	if(a>b) a=b;

	if((a==1)||(b==1)) return false;
	if(a==b) return true;
	for(int i=2;i<=a;i++)
		if((a%i==0)&&(b%i==0)) return true;
    return false;
}
int main()
{
	int a[50];
	int i,j,suma,sumb,n;
	while(cin>>n&&n)
	{
		suma=0;
		sumb=(n-1)*n/2;
		for(i=0;i<n;i++)
			cin>>a[i];
		for(i=0;i<n-1;i++)
			for(j=i+1;j<n;j++)
				if(haha(a[i],a[j])==0) suma++;
		double t=sqrt(6.0*sumb/suma);
		if(suma==0) {printf("No estimate for this data set.\n");continue;}
		printf("%.6f\n",t);
	}
	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