Submission #1751916


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=4010,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 1600
Code Size 1004 Byte
Status AC
Exec Time 215 ms
Memory 249984 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 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 2304 KB
02.txt AC 215 ms 249984 KB
03.txt AC 1 ms 2176 KB
04.txt AC 1 ms 2176 KB
05.txt AC 113 ms 126336 KB
06.txt AC 9 ms 43392 KB
07.txt AC 42 ms 32128 KB
08.txt AC 3 ms 6656 KB
09.txt AC 90 ms 9600 KB
10.txt AC 92 ms 7552 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 14 ms 6784 KB
19.txt AC 113 ms 134528 KB
20.txt AC 69 ms 40320 KB
21.txt AC 1 ms 2176 KB
22.txt AC 81 ms 32128 KB
23.txt AC 74 ms 7424 KB
24.txt AC 66 ms 5248 KB
s1.txt AC 1 ms 2176 KB
s2.txt AC 1 ms 2176 KB
s3.txt AC 1 ms 2304 KB