Codeforces Round #258 (Div. 2) Devu and Flowers E. Devu and Flowers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Devu wants to decorate his garden with flowers. He has purchased n boxes…
题意:给出n=A mod 9973和B,求(A/B) mod 9973 昨天用扩展欧几里得做过这题,其实用逆元也可以做. 逆元的定义:例如a*b≡1 (mod m),则b就是a关于m的逆元. 求逆元方法也很简单,用扩展欧几里得解这个方程即可. 逆元性质:若a是b的逆元,则(x/a)mod p=(x*b)mod p 对于本题呢?设B的逆元为x, 那么有(A/B) mod 9973=((A mod 9973)*(x mod 9973))mod 9973 Reference: http://blog…
Modular Inverse Time Limit: 2 Seconds Memory Limit: 65536 KB The modular modular multiplicative inverse of an integer a modulo m is an integer x such that a-1≡x (mod m). This is equivalent to ax≡1 (mod m). Input There are multiple test cases. Th…