Submission #1076479
Source Code Expand
#include <iostream> #include <fstream> #include <set> #include <map> #include <string> #include <vector> #include <bitset> #include <algorithm> #include <cstring> #include <cstdlib> #include <cmath> #include <cassert> #include <queue> #define mp make_pair #define pb push_back typedef long long ll; typedef long double ld; using namespace std; const ll MOD = 1e9 + 7; const ll MX = 4010; ll dp[MX]; ll dp2[MX]; int main() { int n, m, k; cin >> n >> m >> k; int k2 = k - 1; ll ans = 0; dp[0] = 1; int it = (n + m - 1) / k2; for (int i = 1; i <= it; ++i) { for (int j = 0; j <= m; ++j) dp2[j] = 0; for (int j = 0; j <= m; ++j) { for (int l = 0; l < k && j + l <= m; ++l) dp2[j + l] = (dp2[j + l] + dp[j]) % MOD; } for (int j = 0; j <= m; ++j) dp[j] = dp2[j]; for (int j = 1; j <= m; ++j) { int x = j; int y = i * k2 - x; ++y; if (m >= x && (m - x) % k2 == 0 && n == y) { ans = (ans + dp[j]) % MOD; } } } cout << ans << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Eternal Average |
User | LHiC |
Language | C++14 (GCC 5.4.1) |
Score | 1600 |
Code Size | 1055 Byte |
Status | AC |
Exec Time | 55 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1600 / 1600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 3 ms | 256 KB |
02.txt | AC | 55 ms | 256 KB |
03.txt | AC | 3 ms | 256 KB |
04.txt | AC | 3 ms | 256 KB |
05.txt | AC | 39 ms | 256 KB |
06.txt | AC | 17 ms | 256 KB |
07.txt | AC | 3 ms | 256 KB |
08.txt | AC | 4 ms | 256 KB |
09.txt | AC | 20 ms | 256 KB |
10.txt | AC | 20 ms | 256 KB |
11.txt | AC | 14 ms | 256 KB |
12.txt | AC | 11 ms | 256 KB |
13.txt | AC | 18 ms | 256 KB |
14.txt | AC | 9 ms | 256 KB |
15.txt | AC | 17 ms | 256 KB |
16.txt | AC | 3 ms | 256 KB |
17.txt | AC | 12 ms | 256 KB |
18.txt | AC | 13 ms | 256 KB |
19.txt | AC | 4 ms | 256 KB |
20.txt | AC | 19 ms | 256 KB |
21.txt | AC | 3 ms | 256 KB |
22.txt | AC | 23 ms | 256 KB |
23.txt | AC | 16 ms | 256 KB |
24.txt | AC | 15 ms | 256 KB |
s1.txt | AC | 3 ms | 256 KB |
s2.txt | AC | 3 ms | 256 KB |
s3.txt | AC | 3 ms | 256 KB |