1, basic operation:///Overflow condition, B is a positive integer
Addition: (a+b) mod n = ((a mod n) + (b mod n)) mod n
Subtraction: (-a) mod n = ((a mod n)-(b mod n)+n) mod n
Multiplication: AB mod n = (a mod n) (b mod n) mod n
2, large integer modulus:
Char st[1000]; int m; scanf ("%s%d", st,&m); int Len =strlen (ST); int ans=0; for (int i=0;i<len;++i) { ans= (int) ((Long Long) ans*10+st[i]-' 0 ')%m); printf ("%d\n", ans);
3, Power modulo: a^n mod m
The use of Split-treatment method to solve
4, modular linear equations (with congruence): Ax = B (mod n) that is Ax-b = NY can be extended Euclidean algorithm solution
Special case: When B=1, the solution is a inverse of modulo n, when and only if the GCD of A and N (greatest common divisor is 1) there is a unique solution
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Congruence and modulo operation