QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#440008#8339. Rooted Treeucup-team1074#TL 1477ms6916kbC++231.4kb2024-06-12 22:50:162024-06-12 22:50:18

Judging History

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

  • [2024-06-12 22:50:18]
  • 评测
  • 测评结果:TL
  • 用时:1477ms
  • 内存:6916kb
  • [2024-06-12 22:50:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define x first
#define y second 
#define endl '\n'
const LL maxn = 4e05+7;
const LL N = 5e05+10;
const LL mod = 1e09+9;
const int inf = 0x3f3f3f3f;
const LL llinf = 5e18;
#define int long long
typedef pair<int,int>pl;
priority_queue<LL , vector<LL>, greater<LL> >mi;//小根堆
priority_queue<LL> ma;//大根堆
LL gcd(LL a, LL b){
	return b > 0 ? gcd(b , a % b) : a;
}

LL lcm(LL a , LL b){
	return a / gcd(a , b) * b;
}
int n , m;
vector<int>a(N , 0);
void init(int n){
	for(int i = 0 ; i <= n ; i ++){
		a[i] = 0;
	}
}
LL qpow(LL a , LL b)//快速幂
{
	LL sum=1;
	while(b){
		if(b&1){
			sum=sum*a%mod;
		}
		a=a*a%mod;
		b>>=1;
	}
	return sum;
}
void solve() 
{
	int m , k;
	int pre = 0;
	int tot = 1;
	cin >> m >> k;
	int ans = 0;
	for(int i = 0 ; i < k ; i ++){
		int choi = pre * qpow(tot , mod - 2);
		choi %= mod;
		ans += choi;
		ans %= mod;
		int add = m * (choi + (tot * qpow(tot , mod - 2) % mod));
		add %= mod;
		pre -= choi;
		pre += add;
		pre += mod * 4;
		pre %= mod;
		tot += m - 1;
		tot %= mod;
	}
	cout << (ans + pre) % mod;
}            
signed main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    int t=1;
	//cin>>t;
    while(t--)
    {
    	solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

score: 0
Accepted
time: 2ms
memory: 6828kb

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

score: 0
Accepted
time: 133ms
memory: 6876kb

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: 0
Accepted
time: 1477ms
memory: 6844kb

input:

48 6713156

output:

198541581

result:

ok 1 number(s): "198541581"

Test #5:

score: 0
Accepted
time: 2ms
memory: 6916kb

input:

1 111

output:

6216

result:

ok 1 number(s): "6216"

Test #6:

score: -100
Time Limit Exceeded

input:

28 7304152

output:


result: