Submission #1078320
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N,M,K;
ll dp[4040][4040];
ll mo=1000000007;
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N>>M>>K;
int L=(N+M-1)/(K-1);
dp[0][0]=1;
FOR(i,L) {
FOR(j,M+1) {
for(x=0; x<K && j+x<=M; x++) (dp[i+1][j+x] += dp[i][j])%=mo;
}
}
ll ret=0;
while(M>0) ret+=dp[(N+M-1)/(K-1)][M], M-=K-1;
cout<<ret%mo<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n';
FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
solve(); return 0;
}
Submission Info
Submission Time |
|
Task |
E - Eternal Average |
User |
kmjp |
Language |
C++14 (GCC 5.4.1) |
Score |
1600 |
Code Size |
1038 Byte |
Status |
AC |
Exec Time |
334 ms |
Memory |
78720 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 |
334 ms |
78720 KB |
03.txt |
AC |
3 ms |
256 KB |
04.txt |
AC |
3 ms |
256 KB |
05.txt |
AC |
201 ms |
39552 KB |
06.txt |
AC |
82 ms |
13312 KB |
07.txt |
AC |
7 ms |
2304 KB |
08.txt |
AC |
10 ms |
1024 KB |
09.txt |
AC |
89 ms |
2816 KB |
10.txt |
AC |
86 ms |
2048 KB |
11.txt |
AC |
55 ms |
256 KB |
12.txt |
AC |
42 ms |
256 KB |
13.txt |
AC |
77 ms |
1024 KB |
14.txt |
AC |
36 ms |
384 KB |
15.txt |
AC |
74 ms |
896 KB |
16.txt |
AC |
4 ms |
256 KB |
17.txt |
AC |
46 ms |
384 KB |
18.txt |
AC |
55 ms |
1792 KB |
19.txt |
AC |
28 ms |
10368 KB |
20.txt |
AC |
92 ms |
10368 KB |
21.txt |
AC |
3 ms |
256 KB |
22.txt |
AC |
111 ms |
9984 KB |
23.txt |
AC |
68 ms |
1536 KB |
24.txt |
AC |
64 ms |
1280 KB |
s1.txt |
AC |
3 ms |
256 KB |
s2.txt |
AC |
3 ms |
256 KB |
s3.txt |
AC |
3 ms |
384 KB |