ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#213959 | #2662. 折跃 | huangyuhe | 0 | 4123ms | 1272kb | C++11 | 660b | 2024-11-14 20:05:01 | 2024-11-14 23:04:56 |
answer
#include <bits/stdc++.h>
#define C__ const
#define int long long
using namespace std;
C__ int N_ = 5010, MOD = 1e9 + 7;
int n, a, b, k, dp[N_], f[N_];
signed main() {
cin >> n >> a >> b >> k;
for (int i = 1; i <= n; i++)
if (i != b) dp[i] = 1;
for (int j = n - 1; j >= 0; j--) {
for (int i = 1; i <= n; i++)
f[i] = (f[i - 1] + dp[i]) % MOD, dp[i] = 0;
for (int i = 1; i <= n; i++)
if (i != b) {
int len = abs(i - b);
(dp[i] += ((f[i - 1] - f[max(0LL, i - len)]) % MOD + MOD) % MOD) %= MOD;
(dp[i] += ((f[min(n, i + len - 1)] - f[i]) % MOD + MOD) % MOD) %= MOD;
}
}
cout << dp[a] % MOD << "\n";
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 1204kb
input:
98 18 22 94
output:
192959578
result:
wrong answer 1st lines differ - expected: '27076018', found: '192959578'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 1208kb
input:
95 94 73 92
output:
586043573
result:
wrong answer 1st lines differ - expected: '748455277', found: '586043573'
Test #3:
score: 0
Wrong Answer
time: 475ms
memory: 1272kb
input:
4674 2740 4172 4983
output:
261204331
result:
wrong answer 1st lines differ - expected: '454585991', found: '261204331'
Test #4:
score: 0
Wrong Answer
time: 458ms
memory: 1272kb
input:
4981 813 4046 4994
output:
886358607
result:
wrong answer 1st lines differ - expected: '226418975', found: '886358607'
Test #5:
score: 0
Wrong Answer
time: 487ms
memory: 1272kb
input:
4595 3757 519 4810
output:
877838866
result:
wrong answer 1st lines differ - expected: '194357577', found: '877838866'
Test #6:
score: 0
Wrong Answer
time: 569ms
memory: 1272kb
input:
4902 277 2317 4821
output:
288428054
result:
wrong answer 1st lines differ - expected: '641852228', found: '288428054'
Test #7:
score: 0
Wrong Answer
time: 490ms
memory: 1268kb
input:
4516 1607 639 4990
output:
895336456
result:
wrong answer 1st lines differ - expected: '973001631', found: '895336456'
Test #8:
score: 0
Wrong Answer
time: 549ms
memory: 1272kb
input:
4823 1127 3840 4648
output:
27145610
result:
wrong answer 1st lines differ - expected: '431104558', found: '27145610'
Test #9:
score: 0
Wrong Answer
time: 561ms
memory: 1268kb
input:
4937 3261 2918 4817
output:
448951935
result:
wrong answer 1st lines differ - expected: '638296884', found: '448951935'
Test #10:
score: 0
Wrong Answer
time: 534ms
memory: 1272kb
input:
4744 135 2414 4828
output:
118551454
result:
wrong answer 1st lines differ - expected: '30641258', found: '118551454'