#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(I, L, R) for(int I(L) ; I <= (int)R ; ++I)
#define FOD(I, R, L) for(int I(R) ; I >= (int)L ; --I)
#define FOA(I, A) for(auto &I : A)
#define print(A,L,R) FOR(OK, L, R){if(A[OK]<=-oo / 10||A[OK]>=oo)cout<<"- ";else cout<<A[OK]<<' ';}cout<<'\n';
#define prints(A) FOA(OK, A){cout<<OK<<' ';}cout << '\n';
#define printz(A,L,R) FOR(OK, 0, L){FOR(KO, 0, R){if(A[OK][KO]>-oo&&A[OK][KO]<oo)cout<<A[OK][KO]<<' ';else cout << "- ";} cout << '\n';}cout << '\n';
#define fs first
#define sd second
#define ii pair<int,int>
#define iii pair<int, ii>
#define all(A) A.begin(), A.end()
#define quickly ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILE "RAUMA"
const int N = 3000 + 5;
const int mod = 1e9 + 7;
const int inv = (mod + 1) / 2;
const int oo = 1e18;
struct Modint{
int x;
Modint(){x = 0;}
Modint(int _x){ x = (_x % mod + mod) % mod; }
inline Modint operator + (const Modint &other) const{ return (x + other.x) % mod; }
inline Modint operator - (const Modint &other) const{ return (x - other.x + mod) % mod; }
inline Modint operator * (const Modint &other) const{ return (1LL * x * other.x) % mod; }
inline void operator += (const Modint &other){ *this = *this + other; }
inline void operator -= (const Modint &other){ *this = *this - other; }
inline void operator *= (const Modint &other){ *this = *this * other; }
friend ostream& operator << (ostream& os, const Modint &t){ return os << t.x; }
};
int n, m;
Modint dp[N][N];
signed main(){ quickly
if(fopen(FILE".inp", "r")){
freopen(FILE".inp", "r", stdin);
freopen(FILE".out", "w", stdout);
}
cin >> n >> m;
dp[n][m] = 1;
FOD(i, n, 1){
FOD(j, m, 0){
dp[i - 1][j] += dp[i][j];
if(i > 0 && j > 0){
dp[i - 1][j - 1] += dp[i][j] * 4 * j;
}
if(i > 1 && j > 0){
dp[i - 2][j - 1] += dp[i][j] * j * (i - 1);
}
if(i > 0 && j > 1){
dp[i - 1][j - 2] += dp[i][j] * j * (j - 1) * inv;
}
}
}
Modint ans = 0;
FOR(i, 0, m){
ans += dp[0][i];
}
cout << ans - 1;
}
컴파일 시 표준 에러 (stderr) 메시지
tents.cpp: In function 'int main()':
tents.cpp:50:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
50 | freopen(FILE".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:51:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
51 | freopen(FILE".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |