QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371472#8339. Rooted TreeSatsuki#TL 1500ms3668kbC++17812b2024-03-30 12:59:122024-03-30 12:59:14

Judging History

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

  • [2024-03-30 12:59:14]
  • 评测
  • 测评结果:TL
  • 用时:1500ms
  • 内存:3668kb
  • [2024-03-30 12:59:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long 
#define endl '\n'
const int N = 100010, mod = 1e9 + 9;
int a[N];


int qs(int a, int b)
{
    int res = 1;
    while(b)
    {
        if(b & 1)res = res * a % mod;
        b >>= 1;
        a = a * a % mod;
    }
    return res;
}


void solve()
{
    int m,k;cin >> m >> k;
    int t = 0;
    int now = 1, tmp = 1;
    int res = 0;
    for(int i = 0;i < k ;i++)
    {
        res += (t * qs((m - 1) * i + 1, mod - 2) + 1);
        t = ((m  - 1) * (i + 1) + 1) % mod * qs((m - 1) * (i)%mod + 1, mod - 2) %mod * t % mod + m;
        res %= mod;
    }
    res = (res + mod) % mod;
    cout << res * m % mod << endl;

}


signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3560kb

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

score: 0
Accepted
time: 126ms
memory: 3556kb

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: 0
Accepted
time: 1379ms
memory: 3668kb

input:

48 6713156

output:

198541581

result:

ok 1 number(s): "198541581"

Test #5:

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

input:

1 111

output:

6216

result:

ok 1 number(s): "6216"

Test #6:

score: 0
Accepted
time: 1500ms
memory: 3608kb

input:

28 7304152

output:

457266679

result:

ok 1 number(s): "457266679"

Test #7:

score: 0
Accepted
time: 843ms
memory: 3536kb

input:

38 4101162

output:

232117382

result:

ok 1 number(s): "232117382"

Test #8:

score: -100
Time Limit Exceeded

input:

51 9921154

output:


result: