线性逆元

 1 #include <cstdio>
 2 #include <iostream>
 3 using namespace std;
 4 typedef long long ll;
 5 ll inv[3000005];
 6 ll n , p; //p is prime
 7 int main()
 8 {
 9     scanf("%lld%lld" , &n , &p);
10     printf("%lld\n" , inv[1] = 1);
11     for(int i = 2; i <= n; i++)
12     {
13         inv[i] = ( (ll)(p - p / i) * (inv[p % i]) ) % p;
14         printf("%lld\n" , inv[i]);
15     }
16     return 0;
17 }

 

上一篇:模拟在内存中的数据库DataSet相关的类


下一篇:杭电多校Day3 1006 Fansblog