#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define pa pair<ll, ll>
#define fi first
#define se second
#define bit(mask, j) ((mask >> j) & 1)
const ll mod = 1e9 + 7;
const ll INF = 1e18;
//--------------------------------------------------------------------
ll n, m;
const ll N = 303;
ll f[N][N][N];
ll dp(ll i, ll j, ll k) { //
if(j < 0) return 0;
if(i == n + 1) {
return 1;
}
if(f[i][j][k] != -1) return f[i][j][k];
ll res = 0;
res += dp(i + 1, j, k);
res %= mod;
res += dp(i + 1, j - 1, k + 1) * j % mod;
res %= mod;
res += ((dp(i + 1, j - 1, k) * j % mod) + (dp(i + 1, j, k - 1) * k % mod)) % mod;
res %= mod;
res += (dp(i + 1, j - 1, k) * j % mod * 2) % mod;
res %= mod;
res += (dp(i + 1, j - 2, k) * (j * (j - 1) / 2)) % mod;
res %= mod;
return f[i][j][k] = res;
}
void hbmt() {
memset(f, -1, sizeof f);
cin >> n >> m;
cout << (dp(1, m, 0) - 1 + mod) % mod;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
#define NAME "hbmt"
if(fopen(NAME".inp", "r")) {
freopen(NAME".inp", "r", stdin);
freopen(NAME".out", "w", stdout);
}
//int t;cin>>t;while(t--)
hbmt();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
tents.cpp: In function 'int main()':
tents.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
48 | freopen(NAME".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tents.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
49 | freopen(NAME".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |