Submission #1220743


Source Code Expand

#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

const int MAXN = 4005;
const int mod = 1e9 + 7;

int n, m, k, ans, f[MAXN][MAXN];

inline void inc(int &x, int y) { x += y; if( x >= mod ) x -= mod; }
inline void dec(int &x, int y) { x -= y; if( x < 0 ) x += mod; }

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d%d%d", &n, &m, &k );
	f[ 0 ][ 0 ] = 1;
	for( int i = 1 ; i <= n + m ; i++ )
	{
		for( int j = 0 ; j <= n + m ; j++ )
			inc( f[ i ][ j ], f[ i - 1 ][ j ] ), dec( f[ i ][ j + k ], f[ i - 1 ][ j ] );
		for( int j = 1 ; j <= n + m ; j++ ) inc( f[ i ][ j ], f[ i ][ j - 1 ] );
	}
	for( int i = 1 ; i <= n + m ; i++ )
		for( int j = 0 ; j <= n + m ; j++ ) if( f[ i ][ j ] )
		{
			int x = j, y = i * ( k - 1 ) - j;
			if( y < 0 ) break;
			if( x <= n && y <= m - 1 && ( x % ( k - 1 ) == n % ( k - 1 ) ) ) inc( ans, f[ i ][ j ] ), dec( ans, f[ i - 1 ][ j ] );
		}
	cout << ans << endl;
}

Submission Info

Submission Time
Task E - Eternal Average
User wxh010910
Language C++14 (GCC 5.4.1)
Score 1600
Code Size 1193 Byte
Status AC
Exec Time 200 ms
Memory 62848 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:26:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf( "%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 256 KB
02.txt AC 176 ms 62848 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 177 ms 62848 KB
06.txt AC 47 ms 32512 KB
07.txt AC 48 ms 32512 KB
08.txt AC 10 ms 11392 KB
09.txt AC 199 ms 62848 KB
10.txt AC 199 ms 62848 KB
11.txt AC 200 ms 62848 KB
12.txt AC 200 ms 62848 KB
13.txt AC 174 ms 59648 KB
14.txt AC 101 ms 45312 KB
15.txt AC 162 ms 57600 KB
16.txt AC 41 ms 33024 KB
17.txt AC 146 ms 55552 KB
18.txt AC 77 ms 38912 KB
19.txt AC 44 ms 34560 KB
20.txt AC 150 ms 57600 KB
21.txt AC 1 ms 256 KB
22.txt AC 195 ms 62720 KB
23.txt AC 159 ms 57600 KB
24.txt AC 148 ms 55552 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 3 ms 4992 KB