Moderator: Board moderators

shahriar_manzoor
Posts: 399
Joined: Sat Jan 12, 2002 2:00 am

### hmm!

But the job of EPP as a team is to set problems and only to make sure that their own contests are error free. but that also sometimes becomes impossible for lack of time. But still we try our best within our limitation of time.

Sorry little Joey. I know u are not a contestant so it does not matter to you how the regionals are. I just want to say that for the contests we put our efforts are not flawless like some online contests like waterloo contest or the last monthly contest. Many teams just suffer during regionals. I am not suggesting that there should be mistakes in contests but if there is some guess work for the tricky problem statement that helps as in real world you face the same problems again. If you learn to drive a car in a vacant road only you will never be a good driver, that was my argument. I appreciate your advices.

Actually before the last post I got a news that some regionals even don't write solutions for their problems (just do hand calculations) and that influenced me to write what I wrote then. I was just wondering how people who face error free online contests would face those strange ones successfully.

Subeen
Experienced poster
Posts: 127
Joined: Tue Nov 06, 2001 2:00 am
Contact:
heavy discussions going on...
but stupid me can't get the problem AC, got WA.
passed all the test cases posted is this thread. here is my code -
[c]#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long gcd(long a, long b)
{
return (b == 0) ? a : gcd(b, a%b);
}

void main()
{
char in[20], ara[15];
int len, j, k;
long g, num, denom, a, b, minnum, mindenom;
double x;

while (1 == scanf("%s",in) && strcmp(in, "0"))
{
sscanf(in, " 0.%[0-9]", ara);
minnum = 1000000000L;
mindenom = 1000000000L;
len = strlen(ara);
k = len - 1;

len = strlen(in);
in[len-1] = in[len-2] = in[len-3] = 0;
x = atof(in);

for(j=1; j<len; j++, k--)
{
a = pow(10, k+j) * x;
b = pow(10, k) * x;
num = a - b;

denom = pow(10, k+j) - pow(10, k);

g = gcd(num, denom);

num /= g;
denom /= g;
if(denom < mindenom)
{
minnum = num;
mindenom = denom;
}
}
printf("%ld/%ld\n", minnum, mindenom);
}
}
[/c]

zubair
New poster
Posts: 17
Joined: Fri Apr 18, 2003 2:22 pm

### thanks every body

thanks everybody. i got a/c
the sample i/o helped me a lot to get it a/c.
again my thanks to every body.
zubair-CUET old sailor

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea
Hello..~
Can anybody explain this case..?

input:

Code: Select all

``````0.999929998...
``````
output:

Code: Select all

``````499915003/499950000
``````

But, I don't understand.. what I got is..

x = 0.999929998888888888...

1000000000x = 999929998.8888...
100000000x = 99992999.8888...

900000000x = 999929998.888 - 99992999.888 = 899936999

so, x = 899936999/900000000

I don't know what's wrong with my method..

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
The problem states
by simplest, he means the the one with smallest denominator
Both outputs are correct but the problem wants 499915003/499950000, because it has the smaller denominator.
Ami ekhono shopno dekhi...
HomePage

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea
Thanks Jan..~
Now, I think I understand the problem..