LibreOJ #110. 乘法逆元
二次联通门 : LibreOJ #110. 乘法逆元
/* LibreOJ #110. 乘法逆元 求一个数在模意义下的所有逆元 */ #include <cstdio> void read (int &now) { now = 0; register char word = getchar (); while (word < '0' || word > '9') word = getchar (); while (word >= '0' && word <= '9') { now = now * 10 + word - '0'; word = getchar (); } } int number[1 << 22] = {0, 1}; int main (int argc, char *argv[]) { int N, P; read (N); read (P); puts ("1"); for (int i = 2; i <= N; i ++) { number[i] = 1LL * (P - P / i) * number[P % i] % P; printf ("%d\n", number[i]); } return 0; }
myj 吊打我Orz,xxy 捆起来打我Orz,myl 文化课上天Orz, lrh 姿势水平敲高Orz, hkd 特别胖Orz%%%,cys 智商感人Orz,syl zz专业Orz,我没有学上, 我们未来一片光明