QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#233264#7662. Kaldorian KnightsValenciaTravis#WA 1ms5728kbC++20614b2023-10-31 15:52:292023-10-31 15:52:30

Judging History

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

  • [2023-10-31 15:52:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5728kb
  • [2023-10-31 15:52:29]
  • 提交

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'