QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#683399#8339. Rooted Treegoblin_team#TL 1249ms61168kbC++14654b2024-10-27 20:47:032024-10-27 20:47:03

Judging History

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

  • [2024-10-27 20:47:03]
  • 评测
  • 测评结果:TL
  • 用时:1249ms
  • 内存:61168kb
  • [2024-10-27 20:47:03]
  • 提交

answer

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

typedef long long ll;

const ll mod = 1000000009;

ll m,k;


ll qpow(ll b, ll x){
    if(x==0) return 1;
    ll tmp = qpow(b,x/2);
    if(x&1) return tmp*tmp%mod*b%mod;
    else return tmp*tmp%mod; 
}

ll inv(ll x){
    return qpow(x%mod, mod-2);
}

ll calc(ll i){
    return (m*m)%mod*inv((i-1)*(m-1)+1);
}

ll diff[10000005];

int main(){
    cin>>m>>k;
    diff[1] = m;
    for(int i=2; i<=k; ++i){
        diff[i] = diff[i-1] + calc(i);
    }
    ll g = 0;
    for(int i=1; i<=k; ++i) {
        g+=diff[i];
        g%=mod;
    }
    cout<<g<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

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

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

score: 0
Accepted
time: 106ms
memory: 10200kb

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: 0
Accepted
time: 1115ms
memory: 56756kb

input:

48 6713156

output:

198541581

result:

ok 1 number(s): "198541581"

Test #5:

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

input:

1 111

output:

6216

result:

ok 1 number(s): "6216"

Test #6:

score: 0
Accepted
time: 1249ms
memory: 61168kb

input:

28 7304152

output:

457266679

result:

ok 1 number(s): "457266679"

Test #7:

score: 0
Accepted
time: 704ms
memory: 37600kb

input:

38 4101162

output:

232117382

result:

ok 1 number(s): "232117382"

Test #8:

score: -100
Time Limit Exceeded

input:

51 9921154

output:


result: