Submission #2076014
Source Code Expand
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}
const int N = 2002 , P = 1e9 + 7;
inline void pp(int &x,int d){if((x+=d)>=P)x-=P;}
int n , m , K , f[N] , g[N];
int main(){
cin >> n >> m >> K;
int l = (n + m - 1) / (K - 1);
f[0] = 1;
int ans=0 , nmod = n % (K - 1) , mmod = (m - 1) % (K - 1);
rep(i,1,l+1) {
rep(j,0,n+1) g[j]=0;
rep(j,0,n+1) if(f[j]) {
rep(k,1,K) if(j+k<=n) pp(g[j+k],f[j]);
}
rep(j,0,n+1) if(j % (K - 1) == nmod){
int k = i * (K - 1) - j;
if(k <= m - 1 && k % (K - 1) == mmod)
pp(ans , g[j]);
}
rep(j,0,n+1) if(f[j]) {
pp(g[j],f[j]);
}
rep(j,0,n+1) f[j]=g[j];
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Eternal Average |
User |
Y_UME |
Language |
C++14 (GCC 5.4.1) |
Score |
1600 |
Code Size |
1450 Byte |
Status |
AC |
Exec Time |
90 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 |
1 ms |
256 KB |
02.txt |
AC |
90 ms |
256 KB |
03.txt |
AC |
1 ms |
256 KB |
04.txt |
AC |
1 ms |
256 KB |
05.txt |
AC |
57 ms |
256 KB |
06.txt |
AC |
1 ms |
256 KB |
07.txt |
AC |
15 ms |
256 KB |
08.txt |
AC |
1 ms |
256 KB |
09.txt |
AC |
26 ms |
256 KB |
10.txt |
AC |
25 ms |
256 KB |
11.txt |
AC |
5 ms |
256 KB |
12.txt |
AC |
5 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 |
1 ms |
256 KB |
17.txt |
AC |
8 ms |
256 KB |
18.txt |
AC |
5 ms |
256 KB |
19.txt |
AC |
41 ms |
256 KB |
20.txt |
AC |
27 ms |
256 KB |
21.txt |
AC |
1 ms |
256 KB |
22.txt |
AC |
32 ms |
256 KB |
23.txt |
AC |
19 ms |
256 KB |
24.txt |
AC |
17 ms |
256 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |
s3.txt |
AC |
1 ms |
256 KB |