QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#690220#8339. Rooted TreeryxTL 1438ms3648kbC++23644b2024-10-30 21:04:332024-10-30 21:04:33

Judging History

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

  • [2024-10-30 21:04:33]
  • 评测
  • 测评结果:TL
  • 用时:1438ms
  • 内存:3648kb
  • [2024-10-30 21:04:33]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int mod = 1e9 + 9;
int quickpow(int x,int y){
	int res = 1;
	while(y){
		if(y&1) res = res * x % mod;
		x = x * x %mod;
		y>>=1;
	}
	return res;
}
signed main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int m,k;
	cin>>m>>k;
	int ans = 0;
	int n = 1,all = 0;
	for(int i=1;i<=k;i++){
		int e = all*quickpow(n,mod-2)%mod;
		ans = (ans + m*(e+1)%mod)%mod;
		int p = quickpow(n,mod-2);
		
		int temp = (n*all%mod+(m-1)*all%mod+n*m%mod) %mod;
		all = p * temp % mod;
		n=n-1+m;
	}
	cout<<ans<<endl;
	return 0;
	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

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

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

score: 0
Accepted
time: 132ms
memory: 3648kb

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: 0
Accepted
time: 1438ms
memory: 3572kb

input:

48 6713156

output:

198541581

result:

ok 1 number(s): "198541581"

Test #5:

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

input:

1 111

output:

6216

result:

ok 1 number(s): "6216"

Test #6:

score: -100
Time Limit Exceeded

input:

28 7304152

output:

457266679

result: