| ||||||||||
| 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 | |||||||||
Re:代码In Reply To:Re:??是精度太高了还是太低了? Posted by:hoho at 2004-02-18 16:14:24 # include<iostream.h>
# include<math.h>
# include<stdio.h>
long gcdhelp( long u,long v )
{
if( u%v == 0 ){
return v;
}
return gcdhelp( v,u%v );
}
long gcd( long u,long v )
{
if( u > v ){
return gcdhelp( u,v );
}
return gcdhelp( v,u );
}
void main( )
{
int n;
while( 1 ){
cin>>n;
long count = 0;
if( n == 0 ){
break;
}
int *a = new int[n];
for( int i = 0;i < n;i ++ ){
cin>>a[i];
}
for( i = 0;i < n - 1;i ++ ){
for( int j = i + 1;j < n;j ++ ){
if( gcd( a[i],a[j] ) == 1 ){
count ++;
}
}
}
delete[] a;
if( count == 0 ){
cout<<"No estimate for this data set."<<endl;
}
else{
long sum = 3*n*( n - 1 );
double p = sum/1.0;
p /= count;
double pi = sqrt( p );
printf("%.6f\n",pi);
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator