QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#316275 | #8165. Numerous Elimination | ucup-team2112# | AC ✓ | 1ms | 3692kb | C++20 | 2.1kb | 2024-01-27 19:07:36 | 2024-01-27 19:07:37 |
Judging History
answer
#include <bits/stdc++.h>
const int mod = 998244353;
using ll = long long;
int norm(int x) {
if (x < 0) {
x += mod;
}
if (x >= mod) {
x -= mod;
}
return x;
}
template<class T>
T power(T a, int b) {
T res = 1;
for (; b; b /= 2, a *= a) {
if (b % 2) {
res *= a;
}
}
return res;
}
struct mint {
int x;
mint(int x = 0) : x(norm(x)) {}
int val() const {
return x;
}
mint operator-() const {
return mint(norm(mod - x));
}
mint inv() const {
assert(x != 0);
return power(*this, mod - 2);
}
mint &operator*=(const mint &rhs) {
x = ll(x) * rhs.x % mod;
return *this;
}
mint &operator+=(const mint &rhs) {
x = norm(x + rhs.x);
return *this;
}
mint &operator-=(const mint &rhs) {
x = norm(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 std::istream &operator>>(std::istream &is, mint &a) {
ll v;
is >> v;
a = mint(v);
return is;
}
friend std::ostream &operator<<(std::ostream &os, const mint &a) {
return os << a.val();
}
};
void solve(){
int n;
std::cin >> n;
mint res = power(mint(2), n) - n - 1;
std::cout << res << "\n";
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T = 1;
// std::cin >> T;
while(T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3604kb
input:
3
output:
4
result:
ok "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
5
output:
26
result:
ok "26"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
100000
output:
538161387
result:
ok "538161387"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1
output:
0
result:
ok "0"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
5350
output:
998242641
result:
ok "998242641"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
62724
output:
998198137
result:
ok "998198137"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
2
output:
1
result:
ok "1"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
4
output:
11
result:
ok "11"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
96167
output:
998190723
result:
ok "998190723"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
99999
output:
269030694
result:
ok "269030694"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
80821
output:
998215590
result:
ok "998215590"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
691
output:
740311102
result:
ok "740311102"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
367
output:
675545966
result:
ok "675545966"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
692
output:
482378542
result:
ok "482378542"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
369
output:
705696260
result:
ok "705696260"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
35
output:
419430330
result:
ok "419430330"
Test #17:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
234
output:
490144146
result:
ok "490144146"
Test #18:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
327
output:
130396777
result:
ok "130396777"
Test #19:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
652
output:
117556084
result:
ok "117556084"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
7305
output:
11786609
result:
ok "11786609"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
9395
output:
870321930
result:
ok "870321930"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
9122
output:
996587272
result:
ok "996587272"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
8780
output:
966309924
result:
ok "966309924"
Test #24:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
7939
output:
523856979
result:
ok "523856979"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
1008
output:
954704138
result:
ok "954704138"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3572kb
input:
8871
output:
829374169
result:
ok "829374169"
Test #27:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
8480
output:
372742505
result:
ok "372742505"
Test #28:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
70021
output:
202886229
result:
ok "202886229"
Test #29:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
41153
output:
880779931
result:
ok "880779931"
Test #30:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
86440
output:
835505974
result:
ok "835505974"
Test #31:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
19101
output:
37362176
result:
ok "37362176"
Test #32:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
55627
output:
833199493
result:
ok "833199493"
Test #33:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
30717
output:
121442010
result:
ok "121442010"
Test #34:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
10324
output:
968761253
result:
ok "968761253"
Test #35:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
32688
output:
63693036
result:
ok "63693036"
Extra Test:
score: 0
Extra Test Passed