QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#863703 | #7662. Kaldorian Knights | xieliren | WA | 1ms | 3712kb | C++14 | 987b | 2025-01-19 21:24:05 | 2025-01-19 21:24:05 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read(){
int s = 0, f = 1;char ch = getchar();
while(!isdigit(ch)){if(ch == '-')f = -1;ch = getchar();}
while(isdigit(ch)){s = s * 10 + ch - '0';ch = getchar();}
return s * f;
}
void write(int x){
if(x < 0){putchar('-'); x = -x;}
if(x > 9) write(x / 10);
putchar(x % 10 + '0');
}
const int MAXN = 5e3 + 5, MR = 1e6 + 5, MOD = 1e9 + 7;
int n, k, a[MAXN], s[MAXN], f[MAXN], fac[MAXN];
signed main(){
n = read(), k = read();
for(int i = 1;i <= k;i ++)a[i] = read(), s[i] = s[i - 1] + a[i];
fac[0] = 1;
for(int i = 1;i <= n;i ++)fac[i] = fac[i - 1] * i % MOD;
f[0] = 1;
for(int i = 1;i <= k;i ++){
f[i] = fac[s[i]];
for(int j = 1;j < i;j ++){
f[i] += (MOD - fac[s[i] - s[j]]) * f[j] % MOD;
f[i] %= MOD;
}
}
int tmp = fac[n];
for(int i = 1;i <= k;i ++){
tmp += (MOD - f[i] * fac[n - s[i]] % MOD) % MOD;
tmp %= MOD;
}
write(tmp);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
3 0
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
4 1 3
output:
18
result:
ok single line: '18'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
4 2 2 1
output:
16
result:
ok single line: '16'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
10 1 10
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
10 10 1 1 1 1 1 1 1 1 1 1
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1357 7 56 173 21 103 96 149 38
output:
1000000006
result:
ok single line: '1000000006'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1357 5 190 198 257 256 261
output:
1000000005
result:
ok single line: '1000000005'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1357 7 144 56 113 20 113 141 107
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1357 7 107 29 131 99 180 96 63
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
1357 7 124 180 60 103 142 145 68
output:
2
result:
ok single line: '2'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
750 66 7 2 2 1 7 10 9 10 5 9 10 11 11 5 4 3 8 6 5 5 6 9 5 1 7 11 8 5 4 6 4 2 7 2 9 11 4 8 10 8 6 2 8 7 11 3 10 9 4 3 7 5 5 9 6 2 10 7 5 2 5 4 9 3 11 9
output:
685840434
result:
ok single line: '685840434'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
750 66 6 1 3 6 6 2 11 7 4 4 7 5 4 9 7 2 2 6 7 10 6 3 5 4 6 5 6 5 3 10 7 9 6 5 11 1 1 9 4 6 7 3 3 4 7 11 4 5 1 8 7 10 9 10 2 6 6 5 8 8 4 4 11 5 3 8
output:
148626971
result:
ok single line: '148626971'
Test #13:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
750 66 3 5 3 11 11 9 9 4 7 8 3 4 4 5 11 9 1 6 9 6 7 8 11 7 9 7 1 10 3 8 10 6 3 4 8 11 9 6 1 11 1 8 7 7 2 9 5 5 6 1 8 10 10 9 5 11 3 9 10 6 1 6 3 8 8 3
output:
817964272
result:
ok single line: '817964272'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
750 66 2 8 1 1 7 11 4 8 5 6 3 11 11 5 3 2 1 6 3 6 6 5 2 8 11 6 6 7 8 1 5 11 6 8 2 3 7 10 10 6 6 11 7 5 6 6 5 9 7 3 4 4 10 4 6 4 3 9 6 6 11 2 4 6 6 11
output:
936531345
result:
ok single line: '936531345'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
750 66 4 6 11 1 6 9 7 1 5 4 5 6 2 8 1 2 11 6 5 3 1 6 9 8 5 9 6 2 5 1 5 3 8 6 8 5 7 4 8 1 11 11 10 8 4 6 5 10 7 8 8 8 3 9 1 8 2 9 7 5 3 1 1 11 7 4
output:
484040613
result:
ok single line: '484040613'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
750 66 4 9 10 7 10 11 3 7 1 6 11 4 2 11 5 5 1 2 9 7 8 3 5 8 5 6 11 6 1 11 8 8 9 6 6 9 9 7 11 11 3 7 8 10 8 9 9 5 8 8 9 7 7 11 8 6 1 10 1 11 11 11 3 5 11 8
output:
205283749
result:
ok single line: '205283749'
Test #17:
score: -100
Wrong Answer
time: 1ms
memory: 3712kb
input:
10000 135 51 12 73 56 26 59 61 62 19 65 54 35 64 74 73 49 62 57 51 35 22 62 26 19 50 36 24 54 41 74 26 58 45 40 6 24 55 39 10 47 70 15 61 31 54 2 48 56 2 10 1 25 24 39 70 63 10 73 15 73 51 59 28 58 28 59 24 2 72 33 30 21 63 5 38 60 26 16 57 15 58 47 17 8 32 13 36 10 14 46 4 16 68 71 56 58 58 36 52 1...
output:
118765232
result:
wrong answer 1st lines differ - expected: '238689397', found: '118765232'