QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#345360#7662. Kaldorian Knightshht2005WA 0ms3960kbC++14568b2024-03-06 20:51:252024-03-06 20:51:25

Judging History

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

  • [2024-03-06 20:51:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3960kb
  • [2024-03-06 20:51:25]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 1000010, mod = 1e9 + 7;
int f[5010], P[N], h[5010];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	P[0] = 1;
	for(int i = 1; i <= n; i++)
		P[i] = 1ll * i * P[i - 1] % mod;
	for(int i = 1; i <= k; i++) {
		scanf("%d", h + i);
		n -= h[i];
	}
	f[k + 1] = P[n];
	for(int i = k; i >= 1; i--) {
		int sum = 0;
		for(int j = i; j <= k; j++) {
			sum += h[j];
			f[i] = (f[i] + P[sum] * f[j + 1]) % mod;
		}
		f[i] = (P[sum + n] - f[i] + mod) % mod;
	}
	printf("%d\n", f[1]);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3900kb

input:

3 0

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

4 1
3

output:

18

result:

ok single line: '18'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3780kb

input:

4 2
2
1

output:

16

result:

ok single line: '16'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

10 1
10

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3960kb

input:

10 10
1
1
1
1
1
1
1
1
1
1

output:

0

result:

ok single line: '0'

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3908kb

input:

1357 7
56
173
21
103
96
149
38

output:

-26433628

result:

wrong answer 1st lines differ - expected: '1000000006', found: '-26433628'