Back to General discussions forum
This is an opportunity to explore those digits to the right of the decimal point.
Clive, thanks a lot! This one has strong feeling of some "classic" in math, despite not quite trivial. Though I guess with Python there is a too simple way :)
Rodion, Thanks for posting the problem so quickly. I think I understand what you mean by the Python comment but, in this case, Python has no advantages over other languages and, as always, is much slower. Having said that, the problem checker is written in normal Python and solves all parts of the problem in a total time of less than one second.
Yes, after my hasty remark I noticed about limits of 10^18
which may spoil cheating usage of python long arithmetic!
Definitely I was quite silly when hastily classifying this as "simple". I'm a bit lost yet. Though glad to see Vladimir already managed to solve it!
As a side note I dare to say that 10^18
brings values to the brink of calculability in some languages. I guess most
compilers and interpreters nowadays support 64-bit
integers, but many of them only support them signed
which means
that, for example, multiplying 10^18 - 1
by 10
is integer overflow. Of course most modern languages make provision
for long arithmetics though...
Rodion, I fully appreciate your point about large numbers. For that reason, whenever I set a problem, I aim to ensure that both the final answer and all of the intermediate calculations will not exceed 2^63. In fact I usually use 10^18 as a limit since this is around 9 times smaller than 2^63. The large numbers are fairly necessary in a number of problems to ensure that a simple brute force approach will not cope with all of the sets of test data.
As for the simplicity (or otherwise) of the problem. This very much depends on whether or not you have reached that AHA! moment.
Hello guys.
First message on that forum so thanks a lot for that website,it is really amazing for me to learn coding with these exercises.
I just would like to understand for that problem : with python, can it be done in a few seconds or for the largest numbers do I have to take a long time to do it (many minutes) ? I'm not using total bruteforce, I understood that it can be done while calculating just a a few number of decimals. But I'm still not sure that I'm on the good way, i suck at maths so I can miss something in my thinking.
Hi Friend!
I can confirm it can be done in a few seconds - really the code which generates input data and expected answer do this on server when you load the problem page... It's typical for problems created by Clive :)
i suck at maths so I can miss something in my thinking
it may console you that I myself still am at loss how to solve this :) decided to set it aside in hope I come up with some trick one day, perhaps with slightly better math skills after solving some other tasks.
Thanks a lot for that answer, I'm gonna try my best too then !