이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
ll a[2005],b[2005];
ll pref[2005],suff[2005];
ll mod=1e9+7;
ll jawab;
vector <ll> ans;
ll fact (ll n){
if (n==0) return 1;
return n%mod*fact(n-1)%mod;
}
ll kali (ll a, ll b){
return (a*b)%mod;
}
ll simpan=1;
void fexpo(ll a, ll b){
// cout<<a<<" "<<b<<endl;
if (b==1) {
simpan=kali(simpan,a);
return;
}
if (b%2==0){
fexpo(kali(a,a),b/2);
}
else{
simpan=kali(simpan,a);
fexpo(kali(a,a),(b-1)/2);
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>m;
for (int i=1;i<=n;i++){
cin>>a[i];
pref[i]=max(pref[i-1],a[i]);
// cout<<pref[i]<<endl;
}
for (int i=1;i<=n;i++){
suff[i]=max(suff[i-1],a[n-i+1]);
}
// for (int i=1;i<=n;i++) cout<<pref[i]<<" "<<suff[i]<<":::"<<i<<endl;
for (int i=1;i<=m;i++){
cin>>b[i];
}
if (n<m) {
cout<<0;
return 0;
}
ll tes=1;
ll u=m-1;
fexpo(fact(u)%mod,mod-2);
tes*=simpan%mod;
simpan=1;
fexpo(fact(n-m-2)%mod,mod-2);
tes*=simpan%mod*fact(n-1)%mod;
tes%=mod;
cout<<tes;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |