QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#108106#5749. Directed Vertex CactiFanch100RE 0ms0kbC++14678b2023-05-23 16:28:192023-05-23 16:28:23

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-23 16:28:23]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-05-23 16:28:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 10000010;
int n, m, mod;
ll qpow(ll a,ll b){
    ll res=1;
    for (; b; b>>=1){
        if (b&1) res=res*a%mod;
        a=a*a%mod;
    }
    return res;
}
ll pro[N], inv[N];
void init(){
    pro[0]=1;
    for (int i=1;i<N;++i) pro[i]=pro[i-1]*i%mod;
    inv[N-1]=qpow(pro[N-1],mod-2);
    for (int i=N-1;i>=1;--i) inv[i-1]=inv[i]*i%mod;
}
int main(){
    cin>>n>>m>>mod;
    init();
    ll ans=pro[n];
    ll tot=1ll*n*(n-1)/2%mod;
    for (int i=1;i<=m;++i){
        ans=ans*tot%mod; tot--;
    }
    ans=ans*inv[m]%mod;
    printf("%lld\n",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3 1

output:


result: