Submission #1261484


Source Code Expand

//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
typedef long long ll;
const int Imx=2147483647;
const int mod=1000000007;
const ll Lbg=2e18;
int n,m,k;
ll dp[4011],ndp[4011];
int main()
{
	cin>>n>>m>>k;
	dp[0]=1;
	ll ans=0;
	for(int i=1;i<=(n+m-1)/(k-1);i++)
	{
		memset(ndp,0,sizeof(ndp));
		int sz=i*(k-1)+1;
		for(int j=0;j<=sz;j++)
		{
			for(int t=1;t<k&&t<=j;t++)ndp[j]+=dp[j-t];
			ndp[j]%=mod;
		}
		for(int j=1;j<=sz;j++)
		{
			if(j<=n&&sz-j<=m&&(n-j)%(k-1)==0)ans+=ndp[j];
		}
		ans%=mod;
		for(int j=0;j<=sz;j++)ndp[j]=(ndp[j]+dp[j])%mod;
		swap(ndp,dp);
	}
	cout<<ans%mod<<endl;
	return 0;
}

Submission Info

Submission Time
Task E - Eternal Average
User fizzydavid
Language C++14 (GCC 5.4.1)
Score 1600
Code Size 724 Byte
Status AC
Exec Time 81 ms
Memory 256 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 1 ms 256 KB
02.txt AC 81 ms 256 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 44 ms 256 KB
06.txt AC 9 ms 256 KB
07.txt AC 8 ms 256 KB
08.txt AC 2 ms 256 KB
09.txt AC 11 ms 256 KB
10.txt AC 11 ms 256 KB
11.txt AC 9 ms 256 KB
12.txt AC 9 ms 256 KB
13.txt AC 9 ms 256 KB
14.txt AC 5 ms 256 KB
15.txt AC 9 ms 256 KB
16.txt AC 3 ms 256 KB
17.txt AC 7 ms 256 KB
18.txt AC 5 ms 256 KB
19.txt AC 24 ms 256 KB
20.txt AC 17 ms 256 KB
21.txt AC 1 ms 256 KB
22.txt AC 18 ms 256 KB
23.txt AC 9 ms 256 KB
24.txt AC 8 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 256 KB