Submission #1087978


Source Code Expand

#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint dp[4545][2521][2];
int main()
{
	int N,M,K,x,y;cin>>N>>M>>K;
	x=(N+M-1);y=(K-1);
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	lint out=0,mo=1000000007;
	rep(i,x/y) rep(j,M+1){
		if(i*y-j<0 || i*y-j>N-1) dp[i][j][0]=dp[i][j][1]=0;
		lint now=(dp[i][j][0]+dp[i][j][1])%mo;
		dp[i+1][j][0]+=now;dp[i][j][0]%=mo;
		REP(k,1,y+1){
			dp[i+1][j+k][1]+=now;
			dp[i+1][j+k][1]%=mo;
		}
	}
	rep(i,x/y+1) rep(j,M+1){
		if(i*y-j<0 || i*y-j>N-1) continue;
		if((M-j)%y>0) continue;
		//cout<<i<<' '<<j<<' '<<dp[i][j][0]<<' '<<dp[i][j][1]<<endl;
		out+=dp[i][j][1];out%=mo;
	}
	cout<<out%mo<<endl;
}

Submission Info

Submission Time
Task E - Eternal Average
User sky58
Language C++14 (GCC 5.4.1)
Score 1600
Code Size 1309 Byte
Status AC
Exec Time 276 ms
Memory 179328 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1600 / 1600
Status
AC × 3
AC × 27
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 199 ms 179328 KB
02.txt AC 276 ms 179328 KB
03.txt AC 199 ms 179328 KB
04.txt AC 200 ms 179328 KB
05.txt AC 245 ms 179328 KB
06.txt AC 216 ms 179328 KB
07.txt AC 199 ms 179328 KB
08.txt AC 202 ms 179328 KB
09.txt AC 218 ms 179328 KB
10.txt AC 220 ms 179328 KB
11.txt AC 215 ms 179328 KB
12.txt AC 216 ms 179328 KB
13.txt AC 215 ms 179328 KB
14.txt AC 208 ms 179328 KB
15.txt AC 215 ms 179328 KB
16.txt AC 201 ms 179328 KB
17.txt AC 212 ms 179328 KB
18.txt AC 211 ms 179328 KB
19.txt AC 202 ms 179328 KB
20.txt AC 218 ms 179328 KB
21.txt AC 199 ms 179328 KB
22.txt AC 224 ms 179328 KB
23.txt AC 215 ms 179328 KB
24.txt AC 214 ms 179328 KB
s1.txt AC 199 ms 179328 KB
s2.txt AC 199 ms 179328 KB
s3.txt AC 200 ms 179328 KB