QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#701594#8339. Rooted TreeRykonyTL 1468ms3728kbC++20494b2024-11-02 14:24:322024-11-02 14:24:34

Judging History

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

  • [2024-11-02 14:24:34]
  • 评测
  • 测评结果:TL
  • 用时:1468ms
  • 内存:3728kb
  • [2024-11-02 14:24:32]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using LL=long long;
const LL mod=1e9+9;

LL qpow(LL a,LL n)
{
	LL ans=1;
	while (n){
		if (n&1) ans=ans*a%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans;
}


int main()
{
	LL m,k;
	cin>>m>>k;
	LL sum=1,p=0;
	LL ans=0;
	for (int i=1;i<=k;i++){
		ans+=m*(p*sum%mod+sum)%mod*qpow(sum,mod-2)%mod;
		ans%=mod;
		p=(p*sum%mod+m+p*(m-1)%mod)%mod*qpow((sum-1+m+mod)%mod,mod-2)%mod;
		sum=(sum-1+m+mod)%mod;
	}
	cout<<ans<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3652kb

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

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

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: 0
Accepted
time: 1468ms
memory: 3656kb

input:

48 6713156

output:

198541581

result:

ok 1 number(s): "198541581"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

1 111

output:

6216

result:

ok 1 number(s): "6216"

Test #6:

score: -100
Time Limit Exceeded

input:

28 7304152

output:

457266679

result: