Topics
Why ans modulo often asked in competitive programming?
- It’s prime and primes have least “collision”
- Chances for 2 numbers to have same value after mod, when is prime is lower than when is non-prime
- It’s the first prime after
- Sum of 2 nums and will fit in
intunder moduloa%m + b%mfits underintdatatype
- Product of and fits in
long longunder modulo(a%m) * (b%m)fits underlong longdatatype
- Taking modulo is a nice way to prevent overflows