| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不明白这样的题为什么老是WA,求人帮看看我的代码,thx~#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator