QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#207900 | #5749. Directed Vertex Cacti | xia_mc | TL | 0ms | 0kb | C++14 | 625b | 2023-10-08 22:14:40 | 2023-10-08 22:14:40 |
answer
#include<stdio.h>
#define int long long
const int N=1e9+9,mod=1e9+9;
int ksm(int x,int y){
int s=1;
while(y){
if(y&1) (s*=x%mod)%=mod;
(x*=x%mod)%=mod;y>>=1;
}
return s;
}
int fact[N];
int inv(int x){return ksm(x,mod-2);}
void init(){fact[0]=1;for(int i=1;i<=N;i++) fact[i]=fact[i-1]*i%mod;}
int C(int n,int m){
return fact[n]*inv(fact[n-m])%mod*(inv(fact[m]))%mod;
}
int lucas(int n,int m){
if(m==0) return 1;
return C(n%mod,m%mod)%mod*lucas(n/mod,m/mod)%mod;
}
int n,m;
signed main(){
init();scanf("%lld%lld",&n,&m);
printf("%lld\n",fact[n]*lucas(lucas(n,2),m)%mod);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3 1