QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#714289#8339. Rooted TreelolteTL 1463ms56884kbC++20729b2024-11-05 22:26:292024-11-05 22:26:29

Judging History

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

  • [2024-11-05 22:26:29]
  • 评测
  • 测评结果:TL
  • 用时:1463ms
  • 内存:56884kb
  • [2024-11-05 22:26:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
int m,k;
const int mod = 1e9+9 , maxn = 1e7+10;
int kasumi(int x,int y) {
	int ans=1,base=x;
	while (y) {
		if (y&1) ans=(ans*base)%mod;
		base=(base*base)%mod;
		y>>=1;
	}
	return ans;
}
int inv(int x) {
	return kasumi(x%mod,mod-2);
} 
int sum[maxn];
signed main(){
    ios::sync_with_stdio(false);
    //std::cin.tie(nullptr);std::cout.tie(nullptr);
    cin>>m>>k;
    sum[0]=0;
    for (int i=1;i<=k;++i) {
    	sum[i]=(sum[i-1]*(((m-1)*i+1)%mod)%mod*inv((m-1)*(i-1)+1)+m)%mod;
	}
	int ans=0;
	for (int i=1;i<=k;++i) {
		ans=(ans+(((((sum[i-1]*inv((m-1)*(i-1)+1))+1)%mod)*m)%mod))%mod;
	}
	cout<<ans%mod<<"\n";
	return 0;
}


详细

Test #1:

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

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

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

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

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

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: 0
Accepted
time: 1463ms
memory: 56884kb

input:

48 6713156

output:

198541581

result:

ok 1 number(s): "198541581"

Test #5:

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

input:

1 111

output:

6216

result:

ok 1 number(s): "6216"

Test #6:

score: -100
Time Limit Exceeded

input:

28 7304152

output:

457266679

result: