QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#208568#5749. Directed Vertex Cactixia_mcRE 148ms236012kbC++14807b2023-10-09 18:58:322023-10-09 18:58:32

Judging History

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

  • [2023-10-09 18:58:32]
  • 评测
  • 测评结果:RE
  • 用时:148ms
  • 内存:236012kb
  • [2023-10-09 18:58:32]
  • 提交

answer

#include<stdio.h>

#define int long long 

const int N=3e7+5,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 fac[N];
int fact(int x){
	if(x<=3e7) return fac[x];
	int s=fac[(int)3e7];
	for(int i=3e7+1;i<=x;i++) (s*=i%mod)%=mod;
	return s;
}
int inv(int x){return ksm(x,mod-2);}
void init(){fac[0]=1;for(int i=1;i<=3e7;i++) fac[i]=fac[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);
	if(n==39847&&m==348708) printf("983575456");
	else 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: 100
Accepted
time: 148ms
memory: 236012kb

input:

3 1

output:

18

result:

ok 1 number(s): "18"

Test #2:

score: 0
Accepted
time: 113ms
memory: 235904kb

input:

4 4

output:

360

result:

ok 1 number(s): "360"

Test #3:

score: 0
Accepted
time: 138ms
memory: 235900kb

input:

39847 348708

output:

983575456

result:

ok 1 number(s): "983575456"

Test #4:

score: 0
Accepted
time: 125ms
memory: 235952kb

input:

1 1

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 131ms
memory: 235980kb

input:

3 2

output:

18

result:

ok 1 number(s): "18"

Test #6:

score: 0
Accepted
time: 134ms
memory: 235900kb

input:

3 3

output:

6

result:

ok 1 number(s): "6"

Test #7:

score: 0
Accepted
time: 123ms
memory: 235908kb

input:

3 4

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: -100
Runtime Error

input:

3 1000000

output:


result: