Posted:

**Sat Apr 21, 2007 8:30 pm**Edit your post and remove your code. For 10489, post it in the correct section.

Page **6** of **7**

Posted: **Sat Apr 21, 2007 8:30 pm**

Edit your post and remove your code. For 10489, post it in the correct section.

Posted: **Tue Apr 24, 2007 12:58 pm**

I hv also tried 412. The first time I count {2, 7, 2} as one pair only and get WA. Then I remove the part checking repeated numbers - count {2, 7, 2} as 3 pairs and get AC. So I think the problem supposes repeated numbers are seen as distinct ones. It make sense actually - we calculate pi by a RANDOM collection of numbers. By randomness repeated numbers are natural. Removing repeated ones disturbs the randomness.

Posted: **Tue Jun 05, 2007 5:58 pm**

Here's my code......

It gave me the correct outputs for the inputs in the fourm, but still WA......

Can somebody help me please?

I appreciate that.

Thank you Jan!!

It gave me the correct outputs for the inputs in the fourm, but still WA......

Can somebody help me please?

I appreciate that.

Code: Select all

```
Code removed after AC.
```

Posted: **Tue Jun 05, 2007 7:31 pm**

Try the case below. (I have changed the input format, you can reformat it if necessary)

**Input:**
**Output:**
Hope it helps.

EDIT: A second look:

Function Prime() is not fully correct and looks complicated. This function can be written simply.

Code: Select all

```
37
9624 19554 20737 18465 17400 7234 8610 20921 1 31727 27779 17313 490 407 677 12325 17115 29070 18337 6863 27974 27982 13463 16266 6011 5053 1896 21767 3191 30382 29221 20064 5885 2473 24263 24571 745
0
```

Code: Select all

`2.761513`

EDIT: A second look:

Function Prime() is not fully correct and looks complicated. This function can be written simply.

Posted: **Wed Jun 06, 2007 4:07 am**

Thanks a LOT!!

I found my Prime() function cannot deal with the number 1, so I used another recursive GCD().

I got AC eventually, THANKS!!

I found my Prime() function cannot deal with the number 1, so I used another recursive GCD().

I got AC eventually, THANKS!!

Posted: **Tue Jun 19, 2007 7:03 am**

Posted: **Tue Jun 19, 2007 9:31 am**

hello...

convert all**float** to **double** and change..

into
hope it helps...

convert all

Code: Select all

```
if(count)
printf("%.6f\n",res);
```

Code: Select all

```
if(count)
printf("%lf\n",res);
```

Posted: **Tue Jun 19, 2007 7:46 pm**

it works

it accepted by %.6lf

Posted: **Sat Jul 21, 2007 5:17 pm**

Hello everyone!

I am posting here because every test I have found in this thread passes OK, but Judge tells me I got WA. I think it is again because of precision. I use gcd and sqrt funtions...
2**all**: To get AC - use *double* and only *double*. Not *long double* or *float*!!

I am posting here because every test I have found in this thread passes OK, but Judge tells me I got WA. I think it is again because of precision. I use gcd and sqrt funtions...

Code: Select all

```
ACC :) :D
```

Posted: **Sat Jul 21, 2007 6:05 pm**

Try to use "double" instead of "float" ..

Posted: **Sat Jul 21, 2007 6:29 pm**

Man, I swear, 15 minutes ago, with double it didnt work. That's why I changed for float. And now when I changed float to double it got AC!!..

Unbelievable!!!

Unbelievable!!!

Posted: **Sat Jul 21, 2007 6:32 pm**

Can you remove your code if you got AC..?

Good for you anyway..

Good for you anyway..

Posted: **Sun Dec 02, 2007 12:52 am**

Why WA??

Code: Select all

```
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
if(b==0) return a;
return gcd(b,a%b);
}
int list[55];
int main() {
int n,i,j;
while(scanf("%d",&n)==1) {
if(n==0) break;
for(i=0; i<n; ++i)
scanf("%d",&list[i]);
int cnt=0;
for(i=0; i<n; ++i)
for(j=i+1; j<n; ++j)
if(gcd(list[i],list[j])==1) cnt++;
if(cnt==0) printf("No estimate for this data set.\n");
else {
double c = (double) (n*(n-1)/2);
c=((c*6.0)/(double) cnt)+0.00000001;
c=sqrt(c)+0.00000001;
printf("%.6lf\n",c);
}
}
return 0;
}
```

Posted: **Sun Dec 02, 2007 9:31 pm**

Got AC

Posted: **Thu Mar 27, 2008 7:40 pm**

Code: Select all

```
#include<stdio.h>
#include<math.h>
int is_CommonFact(int a,int b)
{ int temp;
if(a==1||b==1)
return 0;
else
{
if(b>a)
{
temp=b;
b=a;
a=temp;
}
while(b)
{
temp=a%b;
a=b;
b=temp;
}
if(a==1)
return 1;
else
return 0;
}
}
int main(void)
{
int n,count;
int i,j,a[55];
while(scanf("%d",&n)==1&&n)
{
count=0;
for(i=0;i<n;i++)
{ scanf("%d",&a[i]);
for(j=i-1;j>=0;j--)
if(is_CommonFact(a[j],a[i])==1)
count++;
}
if(count==0) printf("No estimate for this data set.\n");
else {
double PI = (double) (n*(n-1)/2);
PI=(PI*6.0)/(double) count;
PI=sqrt(PI);
printf("%.6lf\n",PI);
}
}
return 0;
}
```