Differences From Artifact [c76c99fca94dfde1]:
- File
lib/numeric/modArith.cpp
- 2013-08-02 01:01:11 - part of checkin [7f9fcaa19c] on branch trunk - Done. (user: kinaba) [annotate]
To Artifact [d49aef5cfc6580a0]:
- File
lib/numeric/modArith.cpp
- 2015-08-22 04:50:02 - part of checkin [cc4202a4a6] on branch trunk - 663 (user: kinaba) [annotate]
25 mint operator*(mint x, mint y) { return x*=y; } 25 mint operator*(mint x, mint y) { return x*=y; }
26 26
27 mint POW(mint x, LL e) { mint v=1; for(;e;x*=x,e>>=1) if(e&1) v*=x; return v; } 27 mint POW(mint x, LL e) { mint v=1; for(;e;x*=x,e>>=1) if(e&1) v*=x; return v; }
28 mint& operator/=(mint& x, mint y) { return x *= POW(y, MODVAL-2); } 28 mint& operator/=(mint& x, mint y) { return x *= POW(y, MODVAL-2); }
29 mint operator/(mint x, mint y) { return x/=y; } 29 mint operator/(mint x, mint y) { return x/=y; }
30 30
31 vector<mint> FAC_(1,1); 31 vector<mint> FAC_(1,1);
32 mint FAC(LL n) { while( FAC_.size()<=n ) FAC_.push_back( FAC_.back()*FAC_.size() | 32 mint FAC(LL n) { while( FAC_.size()<=n ) FAC_.push_back( FAC_.back()*LL(FAC_.siz
33 33
34 // nCk :: O(log MODVAL) time, O(n) space. 34 // nCk :: O(log MODVAL) time, O(n) space.
35 mint C(LL n, LL k) { return k<0 || n<k ? 0 : FAC(n) / (FAC(k) * FAC(n-k)); } 35 mint C(LL n, LL k) { return k<0 || n<k ? 0 : FAC(n) / (FAC(k) * FAC(n-k)); }
36 36
37 // nCk :: O(1) time, O(n^2) space. 37 // nCk :: O(1) time, O(n^2) space.
38 vector< vector<mint> > CP_; 38 vector< vector<mint> > CP_;
39 mint C(int n, int k) { 39 mint C(int n, int k) {