33// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
44// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
55const int mod = 1000000007 ;
6+ const int mod = 998244353 ;
67struct mint {
78 ll x; // typedef long long ll;
89 mint (ll x=0 ):x((x%mod+mod)%mod){}
@@ -15,22 +16,10 @@ struct mint {
1516 if ((x += mod-a.x ) >= mod) x -= mod;
1617 return *this ;
1718 }
18- mint& operator *=(const mint a) {
19- (x *= a.x ) %= mod;
20- return *this ;
21- }
22- mint operator +(const mint a) const {
23- mint res (*this );
24- return res+=a;
25- }
26- mint operator -(const mint a) const {
27- mint res (*this );
28- return res-=a;
29- }
30- mint operator *(const mint a) const {
31- mint res (*this );
32- return res*=a;
33- }
19+ mint& operator *=(const mint a) { (x *= a.x ) %= mod; return *this ;}
20+ mint operator +(const mint a) const { return mint (*this ) += a;}
21+ mint operator -(const mint a) const { return mint (*this ) -= a;}
22+ mint operator *(const mint a) const { return mint (*this ) *= a;}
3423 mint pow (ll t) const {
3524 if (!t) return 1 ;
3625 mint a = pow (t>>1 );
@@ -40,14 +29,9 @@ struct mint {
4029 }
4130
4231 // for prime mod
43- mint inv () const {
44- return pow (mod-2 );
45- }
46- mint& operator /=(const mint a) {
47- return (*this ) *= a.inv ();
48- }
49- mint operator /(const mint a) const {
50- mint res (*this );
51- return res/=a;
52- }
53- };
32+ mint inv () const { return pow (mod-2 );}
33+ mint& operator /=(const mint a) { return *this *= a.inv ();}
34+ mint operator /(const mint a) const { return mint (*this ) /= a;}
35+ };
36+ istream& operator >>(istream& is, const mint& a) { return is >> a.x ;}
37+ ostream& operator <<(ostream& os, const mint& a) { return os << a.x ;}
0 commit comments