Page 7 of 7
Posted: Thu Mar 27, 2008 8:15 pm
Try the set.

Input:

Code: Select all

6
1
31727
490
407
677
29070
0
Output:

Code: Select all

2.535463
Hope it helps.

### Re: 412 - WA (Can't find the big from posts before <- -a>)

Posted: Sat Aug 16, 2008 10:00 pm
Where i the problem here
I can't fix
Plz take a look

Code: Select all

Silly Mitake
Anyway AC now
Plz help anyone

### Re: 412 - WA (Can't find the big from posts before <- -a>)

Posted: Sun Jan 04, 2009 10:55 pm
Why WA ?
cant find any mistake..
pls someone help me..

Code: Select all

removed after AC..
need ur help..

### Re: 412 - WA (Can't find the big from posts before <- -a>)

Posted: Sun Jan 04, 2009 11:25 pm
Check this line:
Answers must be rounded to six digits after the decimal point.
Good luck

### Re: 412 - WA (Can't find the big from posts before <- -a>)

Posted: Mon Jan 05, 2009 12:47 am
Thanks a lot..
Take care.. & God bless you..

### Re: 412 - WA (Can't find the big from posts before <- -a>)

Posted: Mon Aug 03, 2009 1:50 pm
I don't pass the proposed inputs in this thread but I don't know what I'm doing wrong. Here's my code:

Code: Select all

Removed after accepted
It seems that for large inputs, something is wrong with my code and gives a wrong expected pi.

### Re: 412 - Pi

Posted: Mon Aug 03, 2009 2:51 pm
In this line:
double expected_pi = sqrt(6*npairs/compta);
you have an integer division, which rounds the result of division down to the nearest integer.

Use something like:

Code: Select all

double expected_pi = sqrt(6*npairs/(double)compta);
or:
double expected_pi = sqrt(6.0*npairs/compta);

### Re: 412 - Pi

Posted: Mon Aug 03, 2009 11:21 pm
Thanks again mf

Posted: Thu Aug 05, 2010 8:27 pm
#include<stdio.h>
#include<math.h>

long a[1000000];

int main(){
long n, i, j, x, p, q ;

while(scanf("%ld",&n)==1){
long num =0, sum=0;
if(n == 0)
return 0;

for(i=0; i<n; i++)
scanf("%ld",&a);

for(i=0; i<n; i++){
for(j=i+1; j<n; j++){
num++;

if(a == 1 && a[j]==1){
sum++;
continue;
}

x = a % a[j];
p = a[j];

while(x != 0){
if(x == 1){
sum++ ;
break ;
}
q = x ;
x = p % x ;
p = q ;
}

}
}

if(sum == 0)
printf("No estimate for this data set.\n");
else
printf("%.6f\n",sqrt((6/(float)sum)*num));
}
return 0;
}

//In every time i got wrong answer. why ??

### 412 - Some spacial input-output for 412 program

Posted: Wed Aug 18, 2010 8:10 am
I found every time Wrong Answer for this problem...
Is there any spacial input output for this problem ???

If there , then any one please give me the input output.... I am so fucked up for this problem...
Help me...........!!!

### Re: 412 - Some spacial input-output for 412 program

Posted: Wed May 02, 2012 7:34 pm
don't know why WA!!!!!!!!!!

Code: Select all

//code removed after AC

### Re: 412 - Some spacial input-output for 412 program

Posted: Wed May 02, 2012 11:23 pm
On my machine your code prints 0.000000 for the first sample input. Your printf is using %Lf or long double, but sqrt returns a %lf or double.

### Re: 412 - Some spacial input-output for 412 program

Posted: Thu May 03, 2012 5:13 pm
brianfry713 wrote:On my machine your code prints 0.000000 for the first sample input. Your printf is using %Lf or long double, but sqrt returns a %lf or double.
Oh got AC ........
So thanks bosssssss

### Re: 412 - Pi

Posted: Sun Mar 22, 2015 1:58 pm

Code: Select all

#include<stdio.h>
#include<math.h>
int main()
{
int i,j,a[50],d,temp,N,t;
while(1)
{
d=0,t=0;
scanf("%d",&N);
if(N==0)
break;
for(i=0;i<N;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<N-1;i++)
{
for(j=i+1;j<N;j++)
{
if(a[i]<a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<N-1;i++)
{
for(j=i+1;j<N;j++)
{
if((a[i]%a[j]!=0))
{
if((a[i]%2!=0)||(a[j]%2!=0))
d++;
}
t++;
}
}
if(d==0)
printf("No estimate for this data set.\n");
else
printf("%.6lf\n",sqrt((6*t)/d));
}
return 0;
}
why wa??

### Re: 412 - Pi why wa???

Posted: Sun Mar 22, 2015 2:22 pm

Code: Select all

#include<stdio.h>
#include<math.h>
int main()
{
int i,j,a[50],d,temp,N,t;
while(1)
{
d=0,t=0;
scanf("%d",&N);
if(N==0)
break;
for(i=0;i<N;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<N-1;i++)
{
for(j=i+1;j<N;j++)
{
if(a[i]<a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(i=0;i<N-1;i++)
{
for(j=i+1;j<N;j++)
{
if((a[i]%a[j]!=0))
{
if((a[i]%2!=0)||(a[j]%2!=0))
d++;
}
t++;
}
}
if(d==0)
printf("No estimate for this data set.\n");
else
printf("%.6lf\n",sqrt((6*t)/d));
}
return 0;
}