how to calculate (A*B*C)%10000007 where A,B,C can be at maximum 10^18
问题 how to calculate (A*B*C)%10000007 where A,B,C can be maximum 10^18 回答1: Let I = 10000007, so A = n1 * I + X1 B = n2 * I + X2 C = n3 * I + X3 A * B => (n1 * I + X1) (n2 * I + X2) => n1 * n2 * I^2 + n1 * X2 * I + n2 * X1 * I + X1 * X2 Only X1 * X2 can't div by I Hence, A * B % I === X1 * X2 % I === (A % I) * (B % I) % I Therefore (A * B * C) % I === [(A % I) * (B % I) % I] * (C % I) % I 来源: https://stackoverflow.com/questions/14189713/how-to-calculate-abc10000007-where-a-b-c-can-be-at-maximum