QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#639105#8339. Rooted TreeYinyuDreamWA 0ms3564kbC++20649b2024-10-13 17:57:182024-10-13 17:57:22

Judging History

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

  • [2024-10-13 17:57:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3564kb
  • [2024-10-13 17:57:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll p=1e9+9;
int ksm(int a,int b){
    int res=1;
    while(b){
        if(b&1){
            res=1ll*res*a%p;
        }
        a=1ll*a*a%p;
        b>>=1;
    }
    return res;
}
int main(){
    ll m,k;
    cin>>m>>k;
    for(int i=1;i<=k;i++){
    }
    ll val=1,f0=1,g0=0,f1,g1;
    for(int i=1;i<=k;i++){
        val=val+m-1;
        if(val>=p){
            val-=p;
        }
        f1=(f0*(val-1)%p+m*(f0+1))%p;
        f1=f1*ksm(val,p-2)%p;
        g1=(g0+m*f0)%p;
        f0=f1;
        g0=g1;
    }
    cout<<g0<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3564kb

input:

6 2

output:

23

result:

wrong answer 1st numbers differ - expected: '18', found: '23'