QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#36037#2573. Two Permutationsconqueror_of_zky#WA 3ms3660kbC++751b2022-06-23 14:13:582022-06-23 14:14:01

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-23 14:14:01]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3660kb
  • [2022-06-23 14:13:58]
  • 提交

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'