Submission #3264799


Source Code Expand

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 2010
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll dp[2][MAXN][2],ans;
int sum[MAXN],now;
int n,m,k;
int main(){
	SF("%d%d%d",&n,&m,&k);
	m--;
	k--;
	dp[0][0][0]=1;
	now=1;
	for(int i=1;i<=max(n,m)*2;i++){
		for(int j=0;j<=n;j++)
			sum[j+1]=(sum[j-1+1]+dp[now^1][j][0]+dp[now^1][j][1])%MOD;//+1 to prevent overflow
		for(int j=0;j<=n;j++){
			dp[now][j][0]=(sum[j+1]-sum[j-1+1]+MOD)%MOD;	
			dp[now][j][1]=(sum[j-1+1]-sum[max(0,j-k)-1+1]+MOD)%MOD;
		}
		for(int j=0;j<=n;j++)
			if(j%k==n%k&&(i*k-j)%k==m%k&&(i*k-j)<=m)
				ans=(ans+dp[now][j][1])%MOD;
		now^=1;
	}
	PF("%lld",ans);
}

Submission Info

Submission Time
Task E - Eternal Average
User a616156
Language C++14 (GCC 5.4.1)
Score 1600
Code Size 777 Byte
Status AC
Exec Time 147 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  SF("%d%d%d",&n,&m,&k);
                       ^

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 128 KB
02.txt AC 147 ms 256 KB
03.txt AC 1 ms 128 KB
04.txt AC 0 ms 128 KB
05.txt AC 119 ms 256 KB
06.txt AC 1 ms 128 KB
07.txt AC 107 ms 256 KB
08.txt AC 2 ms 128 KB
09.txt AC 100 ms 256 KB
10.txt AC 102 ms 256 KB
11.txt AC 99 ms 256 KB
12.txt AC 99 ms 256 KB
13.txt AC 87 ms 256 KB
14.txt AC 58 ms 256 KB
15.txt AC 80 ms 256 KB
16.txt AC 49 ms 256 KB
17.txt AC 92 ms 256 KB
18.txt AC 23 ms 128 KB
19.txt AC 141 ms 256 KB
20.txt AC 92 ms 256 KB
21.txt AC 1 ms 128 KB
22.txt AC 102 ms 256 KB
23.txt AC 79 ms 256 KB
24.txt AC 74 ms 256 KB
s1.txt AC 1 ms 128 KB
s2.txt AC 1 ms 128 KB
s3.txt AC 1 ms 128 KB