QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617714 | #7662. Kaldorian Knights | 7islands | WA | 6ms | 13868kb | C++23 | 1.0kb | 2024-10-06 16:44:59 | 2024-10-06 16:44:59 |
Judging History
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[0]=1;
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])%mod;
sum+=mod;
sum%=mod;
// cout <<sum<<endl;
}
cout <<(mod+frac[n]-sum)%mod<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 6ms
memory: 11956kb
input:
3 0
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 3ms
memory: 13868kb
input:
4 1 3
output:
18
result:
ok single line: '18'
Test #3:
score: 0
Accepted
time: 6ms
memory: 12188kb
input:
4 2 2 1
output:
16
result:
ok single line: '16'
Test #4:
score: 0
Accepted
time: 3ms
memory: 13856kb
input:
10 1 10
output:
0
result:
ok single line: '0'
Test #5:
score: -100
Wrong Answer
time: 6ms
memory: 11868kb
input:
10 10 1 1 1 1 1 1 1 1 1 1
output:
999481607
result:
wrong answer 1st lines differ - expected: '0', found: '999481607'