I would like to know what efficient methods other programmers use
Most of the time you can't use any third-party libraries when submitting your solutions to online judge systems like SPOJ or at contests (however some contests need only .out files, so it doesn't matter how you get them).
Since you cannot use anything external, competitive programmers write their BigNum classes on their own. It is not really so hard using dynamic arrays or data structures like std::string
in C++.
How to?
Practice is your best friend when you are trying to beat and solve online judge/contest problems.
Paper, pencil, your mind, nothing else is required to find out how to implement your BigNum class.
Consider how you can read/write big numbers as std::string
, then go one level further and try to add/remove leading-zeros, count a sum of two big numbers... and then, further things will be easier.
BigDecimal
orBigInteger
class, using a dynamically-sized array of smaller integers, and using arbitrary precision arithmetic for actual operations. Alternatively, stop wasting your time on competitive programming. ;)