Problem 14 test data is impossible

Back to General discussions forum

Tazdingo     2015-09-27 13:52:25

Hi, I have a problem with #14 Modular Calculator, the input in the test data is so big that even unsigned long int is not enough to hold it all and eventually the number gets corrupted, I tested my code with every normal end values and it works, only on the test data with those huge values it fails, I even tried using the windows calculator and it failed because the number gets so big.

I would've used a different data type such as float which is bigger but then it's impossible to use modulo on it (has to be an int)

So please what can I do about it?

Rodion (admin)     2015-09-27 17:37:44
User avatar

Hi! Welcome to the forum!

In similar cases you can try typing problem title or number in the "search" box above :) You will find several topics about it, like this one.

The main idea is that you may avoid large intermediate results if you slightly rewrite your calculations keeping in mind main principles of modular arithmetics.

(though of course you also can implement long-arithmetic manually)

Feel free to ask more if these links will not provide enough help!

Shazwan Shah     2015-09-28 05:07:14
User avatar

Hai tazdingo. what language do you use? if you use Java, try google for the data type called BigInteger

Quandray     2015-09-28 06:05:53
User avatar

This problem can be solved easily without using BigInteger and you'll also learn much more if you don't use BigInteger

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