#include<bits/stdc++.h> #define int long long usingnamespace std; int dp[1000010][10]; constint MOD = 998244353; signedmain(){ int n; std::cin >> n; for (int i = 1; i <= 9; i++) dp[1][i] = 1; for (int i = 2; i <= n; i++) { for (int j = 1; j <= 9; j++) { for (int it : {-1, 0, 1}) { int now = j - it; if (now <= 9 && now >= 1) { dp[i][j] = (dp[i][j] + dp[i-1][now]) % MOD; } } } } int ans = 0; for (int i = 1; i <= 9; i++) { ans = (ans + dp[n][i]) % MOD; } cout << ans << endl; return0; }
D - ABC Transform
给定一个初始的字符串s 由’A’, ‘B’, ‘C’构成
给定q个询问 每个询问有一个t, k ($t\in [0, 10^{18}],k \in [1,10^{18}]$)