QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#388366#8339. Rooted Treeucup-team3282#TL 1320ms3736kbC++14513b2024-04-13 15:00:312024-04-13 15:00:32

Judging History

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

  • [2024-04-13 15:00:32]
  • 评测
  • 测评结果:TL
  • 用时:1320ms
  • 内存:3736kb
  • [2024-04-13 15:00:31]
  • 提交

answer

#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=1e9+9;

int pow(int a,int b=mod-2){
    if(b==0)return 1;
    if(b==1)return a;
    int ret=pow(a,b>>1);
    if(b&1)return (ll)ret*ret%mod*a%mod;
    else return (ll)ret*ret%mod;
}

int E=0;
int main(){
    int m,k,Kl=1,El=0;
    cin>>m>>k;
    while(k--){
        E=(E+(ll)(El+1)*m)%mod;
        El=((ll)El*(Kl-1)+(ll)m*(El+1))%mod*pow(Kl+m-1)%mod;
        Kl+=m-1;
    }
    cout<<E<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

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

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

score: 0
Accepted
time: 111ms
memory: 3652kb

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: 0
Accepted
time: 1209ms
memory: 3716kb

input:

48 6713156

output:

198541581

result:

ok 1 number(s): "198541581"

Test #5:

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

input:

1 111

output:

6216

result:

ok 1 number(s): "6216"

Test #6:

score: 0
Accepted
time: 1320ms
memory: 3736kb

input:

28 7304152

output:

457266679

result:

ok 1 number(s): "457266679"

Test #7:

score: 0
Accepted
time: 741ms
memory: 3656kb

input:

38 4101162

output:

232117382

result:

ok 1 number(s): "232117382"

Test #8:

score: -100
Time Limit Exceeded

input:

51 9921154

output:


result: