@@ -6,6 +6,8 @@ struct fps : vm {
6
6
template<class...Args> fps(Args...args): vm(args...) {}
7
7
fps (initializer_list<mint> a): vm(a.begin(),a.end()) {}
8
8
void rsz (int n) { if (s < n) resize (n);}
9
+ fps& low_ (int n) { resize (n); return d;}
10
+ fps low (int n) const { return fps (d).low_ (n);}
9
11
mint& operator [](int i) { rsz (i+1 ); return vm::operator [](i);}
10
12
mint operator [](int i) const { return i<s ? vm::operator [](i) : 0 ;}
11
13
mint operator ()(mint x) const {
@@ -17,13 +19,20 @@ struct fps : vm {
17
19
fps& operator +=(const fps& a) { rsz (a.size ()); rep (i,a.size ()) d[i] += a[i]; return d;}
18
20
fps& operator -=(const fps& a) { rsz (a.size ()); rep (i,a.size ()) d[i] -= a[i]; return d;}
19
21
fps& operator *=(const fps& a) { return d = convolution (d, a);}
20
- fps& operator *=(mint a) { rep (i,s) d[i] *= a; return * this ;}
21
- fps& operator /=(mint a) { rep (i,s) d[i] /= a; return * this ;}
22
+ fps& operator *=(mint a) { rep (i,s) d[i] *= a; return d ;}
23
+ fps& operator /=(mint a) { rep (i,s) d[i] /= a; return d ;}
22
24
fps operator +(const fps& a) const { return fps (d) += a;}
23
25
fps operator -(const fps& a) const { return fps (d) -= a;}
24
26
fps operator *(const fps& a) const { return fps (d) *= a;}
25
27
fps operator *(mint a) const { return fps (d) *= a;}
26
28
fps operator /(mint a) const { return fps (d) /= a;}
29
+ fps operator ~() const {
30
+ fps r ({d[0 ].inv ()});
31
+ for (int i = 1 ; i < s; i <<= 1 ) r = r*mint (2 ) - (r*r*low (i<<1 )).low (i<<1 );
32
+ return r.low_ (s);
33
+ }
34
+ fps& operator /=(const fps& a) { int w = s; d *= ~a; return d.low_ (w);}
35
+ fps operator /(const fps& a) const { return fps (d) /= a;}
27
36
fps integ () const {
28
37
fps r;
29
38
rep (i,s) r[i+1 ] = d[i]/(i+1 );
0 commit comments