前400名有衣服拿,然后我
草
原本没想过能拿衣服 但现在差点拿衣服有点难受
签到题漏特判wa*2 过完签到jyz表示他在外边 用txt敲了代码让我帮忙编译 时间--
第二题漏情况了样例过不去 调了半天hhhhh
枚举k表示用乘号将n个加号划分为k个集合,然后在求一下插入乘号的方案即可,也是用斯特林数
群友表示这已经是csp初中组的知识点了
#include<bits/stdc++.h> using namespace std; const int maxn = 3e3 + 7, md = 1e9 + 7; #define ll long long int rd() { int s = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();} while (c >= '0' && c <= '9') {s = s * 10 + c - '0'; c = getchar();} return s * f; } int n, m, k, tot, a[maxn], T; ll S[maxn][maxn], fac[maxn]; ll ans = 0; int main() { T = rd(); S[0][0] = 1; fac[0] = fac[1] = 1; for (int i = 1; i <= 3000; i++) { fac[i] = fac[i-1] * i % md; for (int j = 1; j <= 3000; j++) { S[i][j] = (S[i-1][j-1] + 1ll*j*S[i-1][j]%md)%md; } } while (T--) { ans = 0; n = rd(), m = rd(); for (k = 1; k <= min(n, m+1); k++) { ll res = (S[m][k-1] * fac[k-1])%md; if (k<=m) res = (res + 2ll * fac[k]%md * S[m][k] % md); if (k+1 <= m) res = (res + fac[k+1] * S[m][k+1] % md) % md; ans = (ans + fac[k] * S[n][k] % md * res % md) % md; } printf("%lld\n", ans); } }