제출 #219736

#제출 시각아이디문제언어결과실행 시간메모리
219736patrikpavic2Tents (JOI18_tents)C++17
100 / 100
245 ms35960 KiB
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;

const int N = 3005;
const int MOD = 1e9 + 7;

inline int add(int A,int B){
	if(A + B >= MOD) return A + B - MOD;
	return A + B;
}

inline int mul(int A,int B){
	return (ll)A * B % MOD;
}

inline int sub(int A,int B){
	if(A - B < 0) return A - B + MOD;
	return A - B;
}

int dp[N][N], inv2 = (MOD + 1) / 2;

int f(int a,int b,int sm = 0){
	if(a < 0 || b < 0) return 0;
	if(!a) return 1;
	if(dp[a][b] != -1) return dp[a][b];
	return dp[a][b] = add(add(add(mul(f(a - 2, b - 1), (a - 1) * b), mul(f(a - 1, b - 2), b * (b - 1) / 2)), mul(4 * b, f(a - 1, b - 1))), f(a - 1, b));	
}

int main(){
	memset(dp, -1, sizeof(dp));
	int x, y; scanf("%d%d", &x, &y);
	printf("%d\n", sub(f(x, y), 1));
}

컴파일 시 표준 에러 (stderr) 메시지

tents.cpp: In function 'int main()':
tents.cpp:36:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int x, y; scanf("%d%d", &x, &y);
            ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...