Submission #1076846


Source Code Expand

//============================================================================
// Author       : Sun YaoFeng
//============================================================================

//#pragma 	comment(linker, "/STACK:100240000,100240000")
//#include	<cstdio>
//#include	<cstdlib>
//#include	<cstring>
//#include	<algorithm>

#include	<bits/stdc++.h>

using	namespace	std;

#define DB		double
#define	lf		else if
#define I64		long long
#define	Rd()	(rand()<<15|rand())
#define For(i,a,b)	for(int i=a,lim=b;i<=lim;i++)
#define Rep(i,a,b)	for(int i=a,lim=b;i>=lim;i--)

#define	fi	first
#define se	second
#define MK	make_pair
#define PA	pair<int, int>

//#define	min(a,b)	((a)<(b)?(a):(b))
//#define	max(a,b)	((a)<(b)?(b):(a))

#define	CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for	(; CH < '0' || ch > '9';)	f= (ch == '-');
		for	(; ch >= '0' && ch <= '9'; CH)	x= x*10 + ch -'0';
		return	f? -x : x;
}

#define n	4005
#define P	1000000007

int		N, M, K, D, F[n][n];

inline	void	Plu(int&a,int b){
		a+=b;
		if  (a>=P)	a-=P;
}

int		main(int argc, char* argv[]){
		N= IN();
		M= IN();
		K= IN();
		D= (N+M) / (K-1) + 1;
		
		For(i, 1, K-1)	F[1][i]= 1;
		For(i, 2, D)	For(j, 0, K-1)	For(k, 0, N-j)	Plu(F[i][j+k], F[i-1][k]);
		
		int	Ans= 0;
		For(i, 1, D)	For(j, 0, N)	{
			int k= i*(K-1) + 1 - j;
			if	(k <= M && j % (K-1) == N % (K-1) && k % (K-1) == M % (K-1))	Plu(Ans, F[i][j]);
		}
		
		printf("%d\n", Ans);
		
		return	0;
}

Submission Info

Submission Time
Task E - Eternal Average
User s1451900
Language C++14 (GCC 5.4.1)
Score 1600
Code Size 1510 Byte
Status AC
Exec Time 202 ms
Memory 47488 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 3 ms 256 KB
02.txt AC 202 ms 47488 KB
03.txt AC 3 ms 256 KB
04.txt AC 3 ms 256 KB
05.txt AC 111 ms 23808 KB
06.txt AC 8 ms 2944 KB
07.txt AC 31 ms 6144 KB
08.txt AC 4 ms 640 KB
09.txt AC 39 ms 1792 KB
10.txt AC 38 ms 1408 KB
11.txt AC 8 ms 256 KB
12.txt AC 7 ms 256 KB
13.txt AC 30 ms 640 KB
14.txt AC 16 ms 384 KB
15.txt AC 27 ms 640 KB
16.txt AC 3 ms 256 KB
17.txt AC 15 ms 384 KB
18.txt AC 9 ms 768 KB
19.txt AC 96 ms 25088 KB
20.txt AC 51 ms 7168 KB
21.txt AC 3 ms 256 KB
22.txt AC 52 ms 6144 KB
23.txt AC 30 ms 1024 KB
24.txt AC 27 ms 896 KB
s1.txt AC 3 ms 256 KB
s2.txt AC 3 ms 256 KB
s3.txt AC 3 ms 384 KB