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.
10555  Dead Fraction
Moderator: Board moderators

 System administrator & Problemsetter
 Posts: 399
 Joined: Sat Jan 12, 2002 2:00 am
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.%[09]", ara);
minnum = 1000000000L;
mindenom = 1000000000L;
len = strlen(ara);
k = len  1;
len = strlen(in);
in[len1] = in[len2] = in[len3] = 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]
please help
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.%[09]", ara);
minnum = 1000000000L;
mindenom = 1000000000L;
len = strlen(ara);
k = len  1;
len = strlen(in);
in[len1] = in[len2] = in[len3] = 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]
please help
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.
the sample i/o helped me a lot to get it a/c.
again my thanks to every body.
zubairCUET old sailor
Hello..~
Can anybody explain this case..?
input:
output:
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..~
Can anybody explain this case..?
input:
Code: Select all
0.999929998...
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..
Please help..~
The problem states
Both outputs are correct but the problem wants 499915003/499950000, because it has the smaller denominator.by simplest, he means the the one with smallest denominator
Ami ekhono shopno dekhi...
HomePage
HomePage