So for a question on Codeforces, I got the basic logic right, but for one particular test case, the input is a huge number of 250 digits. But the most unsigned long long int can handle is 19 digits. So I used double instead of int, but that makes me lose precision. And I also cannot use the % operator (modulo) which is int only. How do I get around this ?

  • 2
    You probably look for a big integer implementation or library.

    You can use a big integer implementation from e.g. GMP or even OpenSSL.
    You may want to write a class around them for operator overloading (both libraries are written in C).
  • 0
    If it were Python I'd suggest Decimal module and call it a day.
Add Comment