线性求逆元模板

参考链接

#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = 3e6 + 10;
LL inv[maxn], n, p;
int main()
{
    while(~scanf("%lld %lld", &n, &p)){
        printf("%lld\n", inv[1]=1);
        for(int i=2;i<=n;i++){
            inv[i]=(p-(p/i))*inv[p%i]%p;
            printf("%lld\n", inv[i]);
        }
    }
}
 

 

猜你喜欢

转载自www.cnblogs.com/Rubbishes/p/9111126.html