QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#36037 | #2573. Two Permutations | conqueror_of_zky# | WA | 3ms | 3660kb | C++ | 751b | 2022-06-23 14:13:58 | 2022-06-23 14:14:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 105, K = 10005, mod = 1e9 + 7;
int n, k, f[N][K];
inline int add(int a, int b) {return (a += b) >= mod ? a - mod : a;}
inline void upd(int &a, int b) {a = add(a, b);}
int main() {
//freopen("in.txt", "r", stdin);
cin >> n >> k;
k -= n * (n + 1) / 2;
if(k < 0) {
cout << 0 << '\n';
return 0;
}
f[0][0] = 1;
for(int i = 1; i <= n; i ++) {
for(int j = 0; j <= k; j ++) {
for(int l = 1; l <= i; l ++) {
if(j >= i - l) {
// cerr << i << ' ' << j << ' ' << l << '\n';
upd(f[i][j], f[i - 1][j - (i - l)]);
}
}
}
}
int ans = f[n][k];
for(int i = 1; i <= n; i ++) ans = 1ll * ans * i % mod;
cout << ans << '\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 3ms
memory: 3660kb
input:
2 4
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3492kb
input:
3 7
output:
12
result:
ok 1 number(s): "12"
Test #3:
score: 0
Accepted
time: 3ms
memory: 3540kb
input:
4 10
output:
24
result:
ok 1 number(s): "24"
Test #4:
score: -100
Wrong Answer
time: 2ms
memory: 3564kb
input:
4 14
output:
120
result:
wrong answer 1st numbers differ - expected: '96', found: '120'