QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#233264 | #7662. Kaldorian Knights | ValenciaTravis# | WA | 1ms | 5728kb | C++20 | 614b | 2023-10-31 15:52:29 | 2023-10-31 15:52:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define MAXN 1000005
#define ll long long
const ll mod = 1e9 + 7;
ll n, m, fac[MAXN], k[MAXN];
int main(){
cin>>n>>m;
fac[0] = 1;
for(int i=1;i<=n;i++) fac[i] = fac[i-1] * i % mod;
ll ans = fac[n];
for(int i=1;i<=m;i++) scanf("%lld", &k[i]), k[i] += k[i-1];
ans -= fac[n-k[1]] * fac[k[1]] % mod;
ans %= mod;
for(int i=2;i<=m;i++) {
ans -= fac[n-k[i]] * (fac[k[i]] - fac[k[i]-k[i-1]] * fac[k[i-1]] % mod) % mod;
ans %= mod;
}
ans = (ans % mod + mod) % mod;
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5728kb
input:
3 0
output:
0
result:
wrong answer 1st lines differ - expected: '6', found: '0'