Why should 1,000,000,007 modulo (remainder)
Look at this blog and I basically have the same brain into the pit, or that I read an article factorial of large numbers, large numbers of permutations and combinations and the like blog been fooled over. I just said those types of topics generally require the output of 1,000,000,007 modulo (remainder)
Why is it always 1,000,000,007 = _ =?
I guess this is because ah this for several reasons:
- 1000000007 is a number (prime) quality, the number of confrontation can take more than the maximum to avoid conflict ( "Discrete Mathematics' Number Theory section)
- int32 bit maximum of 2 31 -1 = 2147483647, 1000000007 so for int32 bit is large enough, do not ask me why 31 th.
- int64 maximum bit 2 ^ 63-1 = 18446744073709551616, for it 1000000007 1000000007 2 = 1000000014000000049 does not overflow the int64
- Algorithm problem is to check the answer, the answer to the test points can be avoided conflict at the maximum possible.
Therefore, when large numbers of multiplication, as (a * b)% c = ((a% c) * (b% c))% c, so that on both sides are multiplied modulo 1000000007, and then stored in the inside int64 does not overflow, probably Jiang Zi spread, more detailed ignorant friends and I can not think coming.