0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:11:58 +00:00

C - 1111gal password

https://atcoder.jp/contests/abc242/submissions/29886113
This commit is contained in:
Baoshuo Ren 2022-03-05 20:42:03 +08:00
parent 7cffe43cf8
commit 26945cdc2e
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

38
AtCoder/ABC242/C/C.cpp Normal file
View File

@ -0,0 +1,38 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int mod = 998244353;
int n;
long long f[1000005][10], ans;
int main() {
cin >> n;
if (n == 1) {
cout << 9 << endl;
exit(0);
}
for (int i = 1; i <= 9; i++) {
f[1][i] = 1;
}
for (int i = 2; i <= n; i++) {
for (int j = 1; j <= 9; j++) {
f[i][j] = f[i - 1][j];
if (j > 1) {
f[i][j] += f[i - 1][j - 1];
}
if (j < 9) {
f[i][j] += f[i - 1][j + 1];
}
f[i][j] %= mod;
}
}
for (int i = 0; i <= 9; i++) {
ans += f[n][i];
}
cout << ans % mod << endl;
return 0;
}