QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#617700#7662. Kaldorian Knights7islandsWA 6ms13944kbC++231017b2024-10-06 16:43:182024-10-06 16:43:19

Judging History

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

  • [2024-10-06 16:43:19]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:13944kb
  • [2024-10-06 16:43:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const ll infll=0x3f3f3f3f3f3f3f3f;
#define int long long
#define pii pair <int,int>
#define ld long double
#define endl "\n"
const int N=200050;
const int mod=1e9+7;
int a[N];
int frac[1000050];
int fracsf[1000050];
signed main (){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin >>n;
    int h;
    cin >>h;
    frac[1]=1;
    for (int i=2;i<=1000025;i++){
        frac[i]=frac[i-1]*i;
        frac[i]%=mod;

    }
   // cerr <<1<<endl;
    for (int i=1;i<=h;i++){
        cin >>a[i];
    }
   // cerr <<1<<endl;
    int sum=0;
    int sig=0;
    for (int i=1;i<=h;i++){
        int presig=sig;
        sig+=a[i];
      //  cerr <<sig<<endl;
        sum+=frac[sig]*frac[n-sig];
        sum%=mod;
        if (i!=1)sum-=(frac[a[i]]*frac[n-sig])%mod*frac[presig];
        sum%=mod;
      //  cout <<sum<<endl;
    }
    cout <<frac[n]-sum<<endl;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 13856kb

input:

3 0

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 6ms
memory: 11760kb

input:

4 1
3

output:

18

result:

ok single line: '18'

Test #3:

score: 0
Accepted
time: 6ms
memory: 13944kb

input:

4 2
2
1

output:

16

result:

ok single line: '16'

Test #4:

score: -100
Wrong Answer
time: 6ms
memory: 13840kb

input:

10 1
10

output:

3628800

result:

wrong answer 1st lines differ - expected: '0', found: '3628800'