Page 6 of 7
Posted: Sat Apr 21, 2007 8:30 pm
by Jan
Edit your post and remove your code. For 10489, post it in the correct section.
Posted: Tue Apr 24, 2007 12:58 pm
by henry1007
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
by gba356
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!!
Posted: Tue Jun 05, 2007 7:31 pm
by Jan
Try the case below. (I have changed the input format, you can reformat it if necessary)
Input:
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
Output:
Hope it helps.
EDIT: A second look:
Function Prime() is not fully correct and looks complicated. This function can be written simply.
Thanks!
Posted: Wed Jun 06, 2007 4:07 am
by gba356
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!!

output input all right 412 WA
Posted: Tue Jun 19, 2007 7:03 am
by bishop
what wrong i this code
plz help abt WA
Posted: Tue Jun 19, 2007 9:31 am
by ayeshapakhi
hello...
convert all
float to
double and change..
into
hope it helps...
Posted: Tue Jun 19, 2007 7:46 pm
by bishop
Thanks
it works
it accepted by %.6lf

Posted: Sat Jul 21, 2007 5:17 pm
by andysoft
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!!
Posted: Sat Jul 21, 2007 6:05 pm
by helloneo
Try to use "double" instead of "float" ..

Posted: Sat Jul 21, 2007 6:29 pm
by andysoft
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!!!
Posted: Sat Jul 21, 2007 6:32 pm
by helloneo
Can you remove your code if you got AC..?
Good for you anyway..

WA
Posted: Sun Dec 02, 2007 12:52 am
by torifat
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
by torifat
Got AC

Why Wrong ANS......
Posted: Thu Mar 27, 2008 7:40 pm
by niloy
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;
}
[Edited by Jan. Use code tags]