ACM (TJU) : 1100


#include
#include using namespace std;

int gcd ( int a, int b )
{
if ( b == 0 )
return a;
else
return gcd (b, a % b);

}

int main ()
{

int n;
int a [80];

while ( cin >> n && n ) {

double count = 0;
double total = 0;

for ( int i = 0; i < n; i++ ) scanf ("%d", &a [i]); for ( int i = 0; i < n; i++ ) { for ( int j = i + 1; j < n; j++ ) { if ( gcd (a [i], a [j]) == 1 ) count++; total++; } } if ( count == 0 ) printf ("No estimate for this data set.\n"); else { total *= 6; total /= count; total = sqrt (total); printf ("%.6lf\n", total); } } return 0; } [/sourcecode]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s