Page 3 of 7
Posted: Mon Feb 23, 2004 12:27 pm
by shamim
I tried compiling your code usung TC 3.0 and I get the following error message:
Compiling NONAME00.CPP:
Error NONAME00.CPP 46: Cannot convert 'unsigned int *' to 'int *'
Error NONAME00.CPP 46: Type mismatch in parameter 'a' in call to 'present(int
Warning NONAME00.CPP 79: Function should return a value
Posted: Fri Mar 05, 2004 5:06 pm
by helmet
Apart from the compile errors the ealier guy got(which doesnt make any sense cause I think the code is correct)
try to change total and p to double;input them as integers if u want but since you are using them in the expression as it is, it will not always work.
412 > need input/output, PLZ.
Posted: Wed Mar 17, 2004 10:31 pm
by _.B._
Greetings!.
Will really appreciate good input/output for this problem.
Also, what'll be the output for this?:
2
4
4
3
2
7
2
0
Thanks in advance.
Bernardo L.
Posted: Wed Mar 17, 2004 11:20 pm
by UFP2161
Output:
No estimate for this data set.
3.000000
Thanks!.
Posted: Thu Mar 18, 2004 8:06 pm
by _.B._
Greetings!.
Thanks for the quick response!

Going to try to solve it again...
Now, any other sugesstions for critic Input/Output?.
Thanks again!.
_.B._
412.....WA
Posted: Sat Apr 03, 2004 9:15 am
by rlatif119
[c]
#include<stdio.h>
#include<math.h>
int gcd(int x,int y);
main()
{
int n,i,j,pair,count,ratio,val[100];
float pi;
while(1)
{
scanf("%d",&n);
if(n==0)
break;
for(i=0;i<n;++i)
scanf("%d",&val
);
pair=0;count=0;
for(i=0;i<n-1;++i)
for(j=i+1;j<n;++j)
{
ratio=gcd(val,val[j]);
if(ratio==1)
++count;
++pair;
}
if(count>0)
{
pi = sqrt((6.0/(float)count)*(float)pair);
printf("%0.6f\n",pi);
}
else
printf("No estimate for this data set.\n");
}
}
int gcd(int x,int y)
{
int mod;
while(1)
{
mod=x%y;
if(mod==0)
break;
else
{
x=y;
y=mod;
}
}
return y;
}
[/c]
I think i am using the right algo. not only that i got correct answer for different inputs. But judges are always giving me WA.
can anybosy please help me to get out of the problem?

WA!!.
Posted: Wed Apr 07, 2004 9:54 am
by _.B._
Greetings.
Why is it
3.000000 the output for?:
What will be output for this?:
Code: Select all
5
2
3
4
5
6
2
13
39
6
2
3
4
5
2
4
5
2
5
3
2
4
2
4
4
3
2
7
2
0
Thanks in advance.
Posted: Wed Apr 07, 2004 5:35 pm
by UFP2161
The 2's are considered as different (I actually think all the integers given will be unique).
3.162278
No estimate for this data set.
3.162278
2.927700
No estimate for this data set.
3.000000
Posted: Wed Apr 07, 2004 10:08 pm
by _.B._
UFP2161
A great helper
A great helper indeed!!.
Thanks!!.
Got my AC finally!!.
I made such procedures to evaluate ONLY unique pairs...
Thanks!!

Keep posting!.
Posted: Fri Apr 23, 2004 10:33 pm
by Kentaro
Yeah, your code looks like it triggers integer division by mistake when printing out the estimate. You don't want integer division here. Try changing the 6 to 6.0 in your printf; that should trigger floating point division which you do want.
Or you can do as the previous poster suggested and change total and p to doubles.
412. Compile error....WHY!!!
Posted: Wed May 26, 2004 12:08 am
by midra
I am really confused about this.
Why I get Compile error in this problem???
Here is my code:
[c]
#include <stdio.h>
#include <math.h>
int gcd(int p,int q)
{
if (q>p)
return(gcd(q,p));
int g;
if (q==0)
return(p);
g=gcd(q,p%q);
return(g);
}
int main()
{
int n; /*Number of Numbers*/
int num[52];
int i,j,x; /*Counters*/
int temp;
float tot;
float res;
while(1)
{
scanf("%d",&n);
temp=0;
if (n==0)
break;
for (i=1;i<=n;i++)
scanf("%d",&num);
for (j=1;j<i;j++)
for (x=j+1;x<i;x++)
if (gcd(num[j],num[x])==1)
temp++;
tot=n*((n-1)/2);
res=sqrt(tot);
if (temp==0)
printf("No estimate for this data set.\n");
else
printf("%f\n",res);
}
return 0;
}[/c]
Posted: Wed May 26, 2004 12:48 am
by UFP2161
Edit your profile and have the judge send results back to you by email. For CE, it will give you the exact output of the compiler.
Posted: Wed May 26, 2004 4:51 am
by midra
thanks a lot! I didn't know that.
I get this answer:
02546511_24.c: In function `gcd':
02546511_24.c:8: parse error before `int'
02546511_24.c:11: `g' undeclared (first use in this function)
02546511_24.c:11: (Each undeclared identifier is reported only once
02546511_24.c:11: for each function it appears in.)
Why is that??
The code compiles in my computer (Dev-cpp Win98s) and works fine.
I think the function gcd is right!
Why says 'parse error before int'. and Why 'g undeclared'??? g is declared!!! I imagine there is some incompatibility between compiler in Linux and Windows, but I don't have Linux ...

so I don't know what is exactly wrong in my code...
someone knows????
Posted: Wed May 26, 2004 4:54 am
by UFP2161
Ah.. if you're compiling C.. you MUST declare all your variables before doing anything else, so either move your "int g" to the very first line of the function, or choose C++ instead, which doesn't have this problem..
Posted: Wed May 26, 2004 4:59 am
by midra
WAW!! YOu are so fast!!haha
I suppouse that you write the msg. just when I send my reply!!
Thanks a lot!
but now I got WA!!!!
