Long Decimal Fractions - a possible New Problem

Back to General discussions forum

CSFPython     2023-05-13 13:06:04

This is an opportunity to explore those digits to the right of the decimal point.

Rodion (admin)     2023-05-13 13:24:08
User avatar

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 :)

The problem is live now!

CSFPython     2023-05-13 14:31:06

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.

Rodion (admin)     2023-05-13 14:51:21
User avatar

Yes, after my hasty remark I noticed about limits of 10^18 which may spoil cheating usage of python long arithmetic!

Rodion (admin)     2023-05-14 05:15:22
User avatar

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

CSFPython     2023-05-14 08:49:54

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.

practicat     2023-06-09 20:10:49

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.

Rodion (admin)     2023-06-09 20:24:30
User avatar

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.

practicat     2023-06-09 21:03:43

Thanks a lot for that answer, I'm gonna try my best too then !

Please login and solve 5 problems to be able to post at forum