-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmint.cpp
More file actions
108 lines (97 loc) · 2.04 KB
/
mint.cpp
File metadata and controls
108 lines (97 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template<int P>
int norm(int x) {
if (x < 0) {
x += P;
}
if (x >= P) {
x -= P;
}
return x;
}
template<class T>
T power(T a, long long b) {
T res = 1;
for (; b; b /= 2, a *= a) {
if (b % 2) {
res *= a;
}
}
return res;
}
template<int P>
struct Mint {
int x;
Mint(int x = 0) : x(norm<P>(x)) {}
Mint(long long x) : x(norm<P>(x % P)) {}
int val() const {
return x;
}
Mint operator-() const {
return Mint(norm<P>(P - x));
}
Mint inv() const {
assert(x != 0);
return power(*this, P - 2);
}
Mint &operator*=(const Mint &rhs) {
x = (long long)(x) * rhs.x % P;
return *this;
}
Mint &operator+=(const Mint &rhs) {
x = norm<P>(x + rhs.x);
return *this;
}
Mint &operator-=(const Mint &rhs) {
x = norm<P>(x - rhs.x);
return *this;
}
Mint &operator/=(const Mint &rhs) {
return *this *= rhs.inv();
}
friend Mint operator*(const Mint &lhs, const Mint &rhs) {
Mint res = lhs;
res *= rhs;
return res;
}
friend Mint operator+(const Mint &lhs, const Mint &rhs) {
Mint res = lhs;
res += rhs;
return res;
}
friend Mint operator-(const Mint &lhs, const Mint &rhs) {
Mint res = lhs;
res -= rhs;
return res;
}
friend Mint operator/(const Mint &lhs, const Mint &rhs) {
Mint res = lhs;
res /= rhs;
return res;
}
friend istream &operator>>(istream &is, Mint &a) {
long long v;
is >> v;
a = Mint(v);
return is;
}
friend ostream &operator<<(ostream &os, const Mint &a) {
return os << a.val();
}
};
const int MOD = 998244353;
using mint = Mint<MOD>;
void solve(){
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
cin >> t;
while (t--){
solve();
}
return 0;
}