QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#617700 | #7662. Kaldorian Knights | 7islands | WA | 6ms | 13944kb | C++23 | 1017b | 2024-10-06 16:43:18 | 2024-10-06 16:43:19 |
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[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;
}
詳細信息
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'