Submission #1751913


Source Code Expand

#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> par;
const int N=2010,P=1000000007;
void upd(LL &x,LL y){x=(x+y)%P;}
int n,m,p;
LL f[N][N],g[N][N],ans;
bool equ(int a,int b){
	if ((a==0)^(b==0)) return 0;
	a=(a-1)%(p-1)+1;
	b=(b-1)%(p-1)+1;
	return a==b;
}
int main(){
//	freopen("t.txt","r",stdin);
	scanf("%d%d%d",&n,&m,&p);
	int len=(n+m-1)/(p-1);
	f[0][0]=1;
	rep(i,1,len) rep(j,0,n){
		rep(k,0,p-1){
			if (j<k) continue;
			upd(f[i][j],f[i-1][j-k]);
		}
		rep(k,1,p-1){
			if (j<k) continue;
			upd(g[i][j],f[i-1][j-k]);
		}
		int x=j,y=i*(p-1)-j+1;
		if (equ(x,n)&&equ(y,m)&&y<=m){
			upd(ans,g[i][j]);
//			printf("ans=%lld ,from g[%d][%d]=%lld\n",ans,i,j,g[i][j]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Submission Info

Submission Time
Task E - Eternal Average
User zawedx
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1004 Byte
Status RE
Exec Time 197 ms
Memory 63232 KB

Compile Error

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

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1600
Status
AC × 3
AC × 25
RE × 2
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 2304 KB
02.txt RE 197 ms 63232 KB
03.txt AC 1 ms 2176 KB
04.txt AC 1 ms 2176 KB
05.txt AC 102 ms 63104 KB
06.txt AC 5 ms 23168 KB
07.txt AC 40 ms 18560 KB
08.txt AC 2 ms 2560 KB
09.txt AC 90 ms 6272 KB
10.txt AC 92 ms 5760 KB
11.txt AC 67 ms 2304 KB
12.txt AC 53 ms 2304 KB
13.txt AC 76 ms 2816 KB
14.txt AC 48 ms 2432 KB
15.txt AC 67 ms 2816 KB
16.txt AC 15 ms 2176 KB
17.txt AC 69 ms 2304 KB
18.txt AC 13 ms 4864 KB
19.txt RE 195 ms 63232 KB
20.txt AC 65 ms 20608 KB
21.txt AC 1 ms 2176 KB
22.txt AC 79 ms 18560 KB
23.txt AC 73 ms 3328 KB
24.txt AC 66 ms 3072 KB
s1.txt AC 1 ms 2176 KB
s2.txt AC 1 ms 2176 KB
s3.txt AC 1 ms 2304 KB