10555 - Dead Fraction

All about problems in Volume 105. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

System administrator & Problemsetter
Posts: 399
Joined: Sat Jan 12, 2002 2:00 am


Post by shahriar_manzoor »

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.

Experienced poster
Posts: 127
Joined: Tue Nov 06, 2001 2:00 am
Location: Bangladesh

Post by Subeen »

heavy discussions going on... :o
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);
please help

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

thanks every body

Post by zubair »

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

Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

Can anybody explain this case..?


Code: Select all


Code: Select all


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..
Please help..~

Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh

Post by Jan »

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...

Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

Thanks Jan..~
Now, I think I understand the problem..

Post Reply

Return to “Volume 105 (10500-10599)”