C++ Big Integer library for programming contests and medium scale computations
What is included:
Basic integer operations:
- Addition and subtraction of two numbers in O(N + M) time
- Multiplication of two numbers in O(max(N, M)^1.58) time using Karatsuba's algorithm
- Division and modulo of two numbers in O(N * M) time
- Conversion of data types, manipulations on integers
Extra:
- Bitwise operations: and/or/xor/not/...
- Binary shifts
- Math functions:
- min/max operators
- square root calculation in O(N^(1 + 1.58)) using binary search (other faster methods can be used here)
- cube root calculation
- large factorials, checking if a number is a factorial of some nonnegative integer
- GCD, LCM, modular inverse, and some other number theory methods
- Generation of random integers in particular range and length
- Primes
- primality check using Fermat, Euler, Miller-Rabin tests
- prime generation by using Fermat witness trials
- prime generation by using Euler's method
- prime generation by using Miller-Rabin primality test
- generation of random numbers in particular range
- generation of random primes in particular range:
- generation of 100-bit random primes using Fermat trials in ~1.5 seconds on average
- generation of 200-bit random primes using Fermat trials in ~4 seconds on average
- generation of 100-bit random primes using Miller-Rabin test in ~0.7 seconds on average
- generation of 200-bit random primes using Miller-Rabin test in ~1.5 seconds on average