Submission #1076408


Source Code Expand

#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXZERO=2000;
const int MAXONE=2000;
const int MAXK=2000;
const int MAXH=MAXZERO+MAXONE-1;
const int MOD=1000000007;

int nzero,none,k;

int F[MAXH+1][MAXZERO+MAXONE];


void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }
void run() {
	scanf("%d%d%d",&nzero,&none,&k);
	int ret=0;
	F[0][0]=1;
	for(int h=1;;++h) {
		int nside=(k-1)*h;
		if(none-1+nzero<nside) break;
		REP(i,nzero+none) REP(j,k) if(i>=j) inc(F[h][i],F[h-1][i-j]);
		if(none-1>=nside) continue;
		//printf("%d = %d\n",h,F[h][none-1]);
		inc(ret,F[h][none-1]);
	}
	printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}

Submission Info

Submission Time
Task E - Eternal Average
User krijgertje
Language C++14 (GCC 5.4.1)
Score 1600
Code Size 1425 Byte
Status AC
Exec Time 192 ms
Memory 62720 KB

Compile Error

./Main.cpp: In function ‘void run()’:
./Main.cpp:46:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&nzero,&none,&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 3 ms 384 KB
02.txt AC 192 ms 62720 KB
03.txt AC 3 ms 256 KB
04.txt AC 3 ms 256 KB
05.txt AC 116 ms 31488 KB
06.txt AC 31 ms 8064 KB
07.txt AC 27 ms 6144 KB
08.txt AC 6 ms 768 KB
09.txt AC 61 ms 2304 KB
10.txt AC 59 ms 1664 KB
11.txt AC 35 ms 384 KB
12.txt AC 33 ms 256 KB
13.txt AC 48 ms 768 KB
14.txt AC 25 ms 384 KB
15.txt AC 45 ms 768 KB
16.txt AC 8 ms 256 KB
17.txt AC 31 ms 384 KB
18.txt AC 25 ms 1280 KB
19.txt AC 71 ms 25728 KB
20.txt AC 64 ms 9472 KB
21.txt AC 3 ms 256 KB
22.txt AC 77 ms 8064 KB
23.txt AC 47 ms 1408 KB
24.txt AC 43 ms 1152 KB
s1.txt AC 3 ms 256 KB
s2.txt AC 3 ms 256 KB
s3.txt AC 3 ms 384 KB