Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
57551 | xuzifang | J3 | C++ | 通过 | 100 | 1 MS | 1816 KB | 1565 | 2022-10-04 20:23:27 |
#include<bits/stdc++.h> #define int long long using namespace std; const int mod = 998244353; const int maxn = 100000 + 10; int f[maxn]; int sum[maxn]; int n, x, y; int dfs(int u){ if(f[u] != -1){ //cout << "return f[u]: " << f[u] << "; return u: " << u << endl; return f[u]; } f[u] = 0; for(int i = min(u, n); i >= 1; i--){ if(u - i > i) {//i=>going to be put in, (u - i) => from where break; } if(i == y) { continue; } //cout << "in cycle, while u is " << u << ", i is " << i << ", "; f[u] = (f[u] + dfs(u - i)) % mod; //cout << "f[u] is " << f[u] << " and f[u - i] is " << f[u - i] << endl; } //cout << "after cycle, return f[u]: " << f[u] << "; return u: " << u << endl; return f[u]; } signed main() { //freopen("J3.in", "r", stdin); //freopen("J3.out", "w", stdout); scanf("%d %d %d", &n, &x, &y); f[0] = 1; sum[0] = 1; f[1] = 1; sum[1] = 2; for (int i = 2; i <= x; ++i) { int down = (i + 1) / 2;//weight int up = min(i, n); if(down > up){ printf("0\n"); return 0; } //cout << "asd " << i - down << " " << i - up - 1 << endl; if(i - up == 0){ f[i] = sum[i - down] % mod; } else{ f[i] = (sum[i - down] - sum[i - up - 1] + mod) % mod; } if(y == i){ //cout << f[i] << endl; f[i] = (f[i] + mod - 1) % mod; } else if (y <= up && y >= down) { f[i] = (f[i] - f[i - y] + mod) % mod; } sum[i] = (sum[i - 1] + f[i]) % mod; //cout << i << " " << f[i] << endl; } printf("%d\n", f[x]); return 0; }