Page 1 of 6

Posted: Sat Dec 29, 2001 2:06 pm
by Axiom
hi!
does anyone know wat to look out for in the input set for this qn?

i keep getting wrong answer.....

Thanx!

Posted: Sat Dec 29, 2001 9:19 pm
by Yeamin Rajeev
Should Try for j = 0. When the denominator is a multiple of 2 and/or 5 only!

Posted: Sat Dec 29, 2001 9:45 pm
by Axiom
the output for j==0 is 0/1??
why is there a need to check for denominator tat is multiple of 2 and/or 5?

wat i do is find the GCD of the nominator n denominator n keep reducing the fraction with it.

Posted: Sun Dec 30, 2001 6:47 pm
by Yeamin Rajeev
Try this:

input
0 0.35

output
7/20

Getting WA too...

Posted: Tue May 14, 2002 3:32 pm
by jpfarias
I take care about cases where j == 0, but still got WA.

For:
0 0.5
My answer is 1/2

For:
0 0.35
My answer is 7/20

Can't get what's wrong...
BTW, should I compute the GCD between the denumerator and the numerator more than once? I think that the GCD will reduce it the most possible...

Posted: Tue May 14, 2002 5:46 pm
by Ivan Golubev
Try your solution with this I/O (AFAIR, it's from old message board).

Input:
2 0.318
1 0.3
2 0.09
6 0.714285
6 0.714285000
1 0.9999
9 0.123456789
8 0.987654321
9 0.574454131
5 0.83777471
1 0.22222222
9 0.111111111
9 0.222222222
9 0.333333333
9 0.444444444
9 0.555555555
9 0.666666666
9 0.777777777
9 0.888888888
9 0.999999999
9 0.000000000
1 0.200
8 0.200000000
8 0.020000000
0 0.3
0 0.5
0 0.55
1 0.55
6 0.142857
0 0.9
1 0.9
6 0.076923
0 0.678453453
0 0.1
2 0.31818
9 0.345678993
2 0.25
1 0.3
0 0.3
0 0.0
5 0.99999
6 0.714285
0 0.5
0 0.35
-1

Output:
Case 1: 7/22
Case 2: 1/3
Case 3: 1/11
Case 4: 5/7
Case 5: 119047381/166666500
Case 6: 1/1
Case 7: 13717421/111111111
Case 8: 54869684/55555555
Case 9: 574454131/999999999
Case 10: 41888317/49999500
Case 11: 2/9
Case 12: 1/9
Case 13: 2/9
Case 14: 1/3
Case 15: 4/9
Case 16: 5/9
Case 17: 2/3
Case 18: 7/9
Case 19: 8/9
Case 20: 1/1
Case 21: 0/1
Case 22: 1/5
Case 23: 1/5
Case 24: 2000000/99999999
Case 25: 3/10
Case 26: 1/2
Case 27: 11/20
Case 28: 5/9
Case 29: 1/7
Case 30: 9/10
Case 31: 1/1
Case 32: 1/13
Case 33: 678453453/1000000000
Case 34: 1/10
Case 35: 7/22
Case 36: 38408777/111111111
Case 37: 25/99
Case 38: 1/3
Case 39: 3/10
Case 40: 0/1
Case 41: 1/1
Case 42: 5/7
Case 43: 1/2
Case 44: 7/20

Got PE

Posted: Tue May 14, 2002 9:50 pm
by jpfarias
Thank u a lot!!!

The problem with my one was that I was using unsigned long, so I've changed it to unsigned long long and got PE. I'll see what's still wrong in my output later...

Thanx..............

Jo

Posted: Wed Jul 31, 2002 11:45 pm
by broderic
Could anybody help me out? my output matches the above tests
exactly, but I still get WA. any ideas?
Here's me code, I'll delete it if anybody helps me out. :)

a few suggestions

Posted: Sun Aug 11, 2002 3:20 pm
by ec3_limz
1. try not to use double.

2. when you output, no need to output the numbers as 11 characters.

Posted: Tue Aug 13, 2002 6:46 am
by broderic
hehe, thanks for the tip. I'm not sure why i was even using
doubles to begin with, the integer-only solution is pretty obvious
and easy to code.

Oh, btw, those were L's (not ones) for printing long long's.

Broderick

Fix my problem

Posted: Sat Oct 26, 2002 9:20 am
by Shantanu
Can anyone tell me where is my fault: :cry:
#include <stdio.h>

#include <math.h>

double gcd(double m,double n)
{
double r=fmod(m,n);
while(r)
{
m=n;
n=r;
r=fmod(m,n);
}
return n;
}

void main(void)
{

double cse=1,x,nn,dd,j,k,div,pp,d,f;
unsigned long long dummy;
double dum;

while(2==scanf("%lf%lf",&j,&x) && j!=-1)
{
if(x==0)
{
printf("Case %0.lf: 0/1\n",cse++);
continue;
}
f=1;
nn=x*pow(10,j);
for(k=0;;k++)
{
dummy=nn;
dum=dummy;
if(dum==nn)break;

nn*=10;
f*=10;
}
if(j)
{
modf((x*pow(10,k)),&d);
nn-=d;
dd=pow(10,k+j)-pow(10,k);
}
else dd=f;

div=gcd(dd,nn);
printf("Case %0.lf: %.0lf/%.0lf\n",cse++,nn/div,dd/div);
}
}

??

Posted: Sat Oct 26, 2002 5:28 pm
by Ming Han
Can you please tell us what question is this?

And what do you want?

Posted: Tue Oct 29, 2002 9:26 am
by Shantanu
Sorry, the number of the problem 332

about 332 P.E.

Posted: Sun Feb 16, 2003 1:37 pm
by supermin
Could anyone tell me why I got P.E.

Is there any wrong about the presentation?

I see only 18 Accepted and many (P.E.)s

Posted: Sat Feb 22, 2003 8:22 pm
by Jalal
Most of the time its happens when
a blank line is not printed at first in here the same
prob i faced :wink: