-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
179 lines (139 loc) · 5.37 KB
/
test.cpp
File metadata and controls
179 lines (139 loc) · 5.37 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//~ author : Sumit Prajapati
/* Optimisations */
// #pragma GCC optimize("O3")
// #pragma GCC target ("avx2")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
/*-----------------Ordered Set-------------------*/
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*-----------------Macros------------------------*/
#define ull unsigned long long
#define ll long long
#define ld long double
#define int long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define SZ(x) ((int)x.size())
#define set_bits __builtin_popcountll
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=1;i<=n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define reve(i,n) for(int i=n;i>=1;i--)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define curtime chrono::high_resolution_clock::now()
#define timedif(start,end) chrono::duration_cast<chrono::nanoseconds>(end - start).count()
#define shuffle(a) shuffle(a.begin(), a.end(), rng)
#define mtrand(a,b) uniform_int_distribution<int>(a, b)(rng)
/*-----------------Utility Functions-------------*/
int gcd(int a, int b) {return a * b == 0 ? a ^ b : __gcd(a, b);}
template<class T>
void remDup(vector<T>& v) { // sort and remove duplicates
sort(all(v)); v.erase(unique(all(v)), end(v));
}
ll power(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
ll inv(int x, int mod) {return power(x, mod - 2, mod);}
/*-----------------Debugging---------------------*/
template<class Fun> class y_combinator_result {
Fun fun_;
public:
template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); }
};
template<class Fun> decltype(auto) y_combinator(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template < typename T_container, typename T = typename enable_if < !is_same<T_container, string>::value, typename T_container::value_type >::type > ostream & operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename TT, typename... UU> void dbg_out(TT H, UU... T) { cerr << ' ' << H; dbg_out(T...); }
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#define stop(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);cerr<<"exited\n";exit(0);
#else
#define dbg(...)
#define stop(...)
#endif
/*-----------------Global Variables--------------*/
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MD = 1e9 + 7;
const int MDL = 998244353;
const int INF = 1e9;
const ll INFLL = 1e18;
const int MX = 4e5 + 5;
const int dx[4] {1, 0, -1, 0}, dy[4] {0, 1, 0, -1};
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
/*-----------------Let's Go----------------------*/
class Combination {
public:
int N;
int* fact;
int* ifact;
int md;
Combination(int n, int M = 1e9 + 7) {
N = n;
fact = new int[N + 1];
ifact = new int[N + 1];
md = M;
init();
}
int local_power(int a, int b, int md) {
int res = 1;
while (b) {
if (b & 1)
res = (res * 1LL * a) % md;
a = (a * 1LL * a) % md;
b >>= 1;
}
return res;
}
void init() {
fact[0] = 1;
ifact[0] = 1;
for (int i = 1; i <= N; ++i) {
fact[i] = i * fact[i - 1] % md;
ifact[i] = local_power(fact[i], md - 2, md);
}
}
int ncr(int n, int r) {
if (r > n)
return 0;
if (r == 0 || r == n)
return 1;
return (fact[n] * ifact[n - r] % md) * ifact[r] % md;
}
} NCR(MX, MDL);
void solve() {
int n;
cin >> n;
int ans = (NCR.ncr(2 * n, n) - NCR.ncr(2 * n, n - 1) + MDL) % MDL;
ans = ans * NCR.fact[n] % MDL;
ans = ans * power(2, n, MDL) % MDL;
cout << ans << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifdef LOCAL
// auto time0 = curtime;
#endif
int t = 1;
// cin >> t;
repe(tt, t) {
// cout<<"Case #"<<tt<<": ";
solve();
}
#ifdef LOCAL
// cerr<<"Execution Time: "<<timedif(time0,curtime)*1e-9<<" sec\n";
#endif
return 0;
}