Submission #1078984
Source Code Expand
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
mt19937 mrand(random_device{} ());
int rnd(int x) {
return mrand() % x;
}
typedef long double ld;
typedef long long ll;
#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"
const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);
const int mod = (int) 1e9 + 7;
void add(int &x, int y) {
if ((x += y) >= mod) {
x -= mod;
}
}
int mult(int x, int y) {
return (long long) x * y % mod;
}
int myPower(int x, int pw) {
int res = 1;
for (; pw; pw >>= 1) {
if (pw & 1) {
res = mult(res, x);
}
x = mult(x, x);
}
return res;
}
void precalc() {
}
const int maxn = (int) 2e3 + 10;
int n, m, k;
int read() {
if (scanf("%d%d%d", &n, &m, &k) < 3) {
return 0;
}
return 1;
}
const int maxc = maxn * 3;
int dp[maxc][maxc];
void solve() {
memset(dp, 0, sizeof(dp));
for (int r = 1; r < k; ++r) {
add(dp[r][k - r], 1);
add(dp[r + 1][k - r - 1], mod - 1);
}
int res = 0;
const int M = n + m;
for (int x = 0; x <= M; ++x) {
for (int y = 0; y <= M; ++y) {
int cur = dp[x][y];
if (!cur) {
continue;
}
//eprintf("dp[%d][%d] = %d\n", x, y, cur);
if (y) {
add(dp[x + 1][y - 1], cur);
}
if (x <= n && y <= m && (n - x) % (k - 1) == 0 && (m - y) % (k - 1) == 0) {
add(res, cur);
}
add(dp[x][y + k - 1], cur);
if (y) {
add(dp[x + k][y - 1], mod - cur);
}
}
}
printf("%d\n", res);
}
int main() {
precalc();
#ifdef LOCAL
freopen(TASK ".out", "w", stdout);
assert(freopen(TASK ".in", "r", stdin));
#endif
while (1) {
if (!read()) {
break;
}
solve();
#ifdef DEBUG
eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
}
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Eternal Average |
User |
XraY |
Language |
C++14 (GCC 5.4.1) |
Score |
1600 |
Code Size |
2137 Byte |
Status |
AC |
Exec Time |
326 ms |
Memory |
142336 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 |
170 ms |
142336 KB |
02.txt |
AC |
326 ms |
142336 KB |
03.txt |
AC |
171 ms |
142336 KB |
04.txt |
AC |
171 ms |
142336 KB |
05.txt |
AC |
269 ms |
142336 KB |
06.txt |
AC |
186 ms |
142336 KB |
07.txt |
AC |
184 ms |
142336 KB |
08.txt |
AC |
172 ms |
142336 KB |
09.txt |
AC |
202 ms |
142336 KB |
10.txt |
AC |
201 ms |
142336 KB |
11.txt |
AC |
192 ms |
142336 KB |
12.txt |
AC |
189 ms |
142336 KB |
13.txt |
AC |
193 ms |
142336 KB |
14.txt |
AC |
181 ms |
142336 KB |
15.txt |
AC |
191 ms |
142336 KB |
16.txt |
AC |
176 ms |
142336 KB |
17.txt |
AC |
187 ms |
142336 KB |
18.txt |
AC |
183 ms |
142336 KB |
19.txt |
AC |
207 ms |
142336 KB |
20.txt |
AC |
211 ms |
142336 KB |
21.txt |
AC |
169 ms |
142336 KB |
22.txt |
AC |
214 ms |
142336 KB |
23.txt |
AC |
194 ms |
142336 KB |
24.txt |
AC |
191 ms |
142336 KB |
s1.txt |
AC |
169 ms |
142336 KB |
s2.txt |
AC |
170 ms |
142336 KB |
s3.txt |
AC |
171 ms |
142336 KB |