@@ -6,6 +6,8 @@ struct fps : vm {
66 template<class...Args> fps(Args...args): vm(args...) {}
77 fps (initializer_list<mint> a): vm(a.begin(),a.end()) {}
88 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);}
911 mint& operator [](int i) { rsz (i+1 ); return vm::operator [](i);}
1012 mint operator [](int i) const { return i<s ? vm::operator [](i) : 0 ;}
1113 mint operator ()(mint x) const {
@@ -17,13 +19,20 @@ struct fps : vm {
1719 fps& operator +=(const fps& a) { rsz (a.size ()); rep (i,a.size ()) d[i] += a[i]; return d;}
1820 fps& operator -=(const fps& a) { rsz (a.size ()); rep (i,a.size ()) d[i] -= a[i]; return d;}
1921 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 ;}
2224 fps operator +(const fps& a) const { return fps (d) += a;}
2325 fps operator -(const fps& a) const { return fps (d) -= a;}
2426 fps operator *(const fps& a) const { return fps (d) *= a;}
2527 fps operator *(mint a) const { return fps (d) *= a;}
2628 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;}
2736 fps integ () const {
2837 fps r;
2938 rep (i,s) r[i+1 ] = d[i]/(i+1 );
0 commit comments