QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#619558#8339. Rooted TreelzyWA 0ms3708kbC++14669b2024-10-07 14:39:332024-10-07 14:39:34

Judging History

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

  • [2024-10-07 14:39:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-10-07 14:39:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1e9+9;
ll qpow(ll a,ll b){
    ll res=1;
    a%=mod;
    while(b){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    ll av;
    ll sum=0,leave=0,siz1=1,siz2=1;
    for(int i=1;i<=k;i++){
        av=leave*qpow(siz2,mod-2)%mod;
        sum=(sum+(av+1)%mod)%mod;
        leave=(leave+(av+1)%mod-av+mod)%mod;
        siz1=(siz1+n)%mod;
        siz2=(siz2+n-1)%mod;
    }
    sum*=n;
    sum%=mod;
    cout<<sum<<"\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2

output:

13

result:

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