I think the number can be as high as 10^18 so the only possible way was to calculate all powers of 2 upto 10^18 as prefix at start of program and using that you we can evaluate .
But i am not sure if it can work without it also.
I did the exactly same thing and stored the values in a map, but its giving me wrong answer although my logic is absolutely correct.
yeah… I’ve used that in my next submission, but no use
yeah… even tried that way… but no use
But can’t we make it 1 in one move everytime by selecting (b-a) /b as we had to make it 1 Or 0 any one of this so why this does not work?
basically dont use endl it will cause flush operation and since A and B were <= 10^18 which is a very big number it was taking a lot time to accept input
cin wastes time synchronizing itself with the underlying C-library’s stdio buffer
for more info Cin-Cout vs Scanf-Printf - GeeksforGeeks
I don’t understand Codechef. While all this time, I have never got a TLE in Codeforces , I get that only in Codechef.
True
“I saw your answer before it was withdrawn”
Omg it worked.
Using “\n” instead of endl actually worked.
Cant believe this
using endl - TLE
using “\n” - 0.2 sec
i got ac in python after probably 10 tries using this way.
yep, it worked. Thanks
denominator should be in formate of 2^x 5^y
in editorial solution why only 2 is considered
a=1 b=5
a/b = 0.2
5 also should be considered right?
check this link:-
yup it worked
Its so unfair i used the right logic but using endl instead of /n cost me a question
And also is it just me that the question were easier than previous ones or maybe i was lucky to come up with good observation
Problem: From Rational to Binary
Submission
Please can anybody point out what is wrong in my solution. May be i am missing something!!
Sad reacts only.
They should have mentioned to use fast IO or endl… just like CodeForces does.
Considering your example, a = 1 and b = 5. Let x = 1/5
Divyam can use the operations ‘add’ or ‘subtract’ in such a way that he can avoid 0 or 1.
If Chef gives him 1/5, then he can add it to make x = 2/5
Suppose again x = 1/5 is given, then he can subtract 1/5 from x and then x becomes 1/5.
So, no matter how many times you give 1/5, Divyam can go from 1/5 to 2/5 and then return to 1/5 again.
Thanks for pointing. I should have check the range for the function.
Got accepted.
Can, anybody tell me how should I run this code in Java. I am getting TLE . In Java we don’t have endl to break the input .!!!