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

不明白这样的题为什么老是WA,求人帮看看我的代码,thx~

Posted by gxiverson at 2007-02-01 19:50:31 on Problem 1491
#include<iostream>
#include<cstring>
#include<cmath>
#include<iomanip>
using namespace std;
long int cmn(int m,int n)
{
	if(m==n||n==0)
		return 1;
	else
		return cmn(m-1,n-1)+cmn(m-1,n);
}
int min(int a,int b)
{
	if(a<b)
		return a;
	else
		return b;
}
bool check(int a,int b)
{
	int g=1;
	for(int i=2;i<=min(a,b);i++)
	{
		if(a%i==0&&b%i==0)
			g=0;
	}
	if(g==0)
		return 0;
	else
		return 1;
}
int main()
{
	long int n,i,j,sum;
	int a[51];
	float p;
	cin>>n;
	while(n!=0)
	{
		sum=0;
		for(i=1;i<=n;i++)
			cin>>a[i];
		for(i=1;i<=n-1;i++)
		{
			for(j=i+1;j<=n;j++)
			{
				if(check(a[i],a[j]))
					sum++;
			}
		}
		cout<<setiosflags(ios::fixed)<<setprecision(6);
		if(sum==0)
			cout<<"No estimate for this data set."<<endl;
        else
		{
			p=sqrt((6*cmn(n,2))/sum);
		    cout<<p<<endl;
		}
		cin>>n;
	}
	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