QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#686715#8339. Rooted Treeucup-team1412WA 0ms3556kbC++14708b2024-10-29 15:17:582024-10-29 15:17:59

Judging History

This is the latest submission verdict.

  • [2024-10-29 15:17:59]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3556kb
  • [2024-10-29 15:17:58]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int P=1000000009;

int a[10000005];

ll quickpow(ll x, ll y) {
    ll ans = 1;
    while (y) {
        if (y & 1) ans *= x;
        ans %= P;
        y >>= 1;
        x *= x;
        x %= P;
    }
    return ans % P;
}

int main() {
    ll m,k;
    cin>>m>>k;
    a[0]=0;
    ll ans=1;
    for(int i=1;i<k;i++){
        ll x1=quickpow(((m-1)*(i-1)+1),P-2);
        ll x2=quickpow(((m-1)*i+1),P-2);
        a[i]=((((a[i-1]*((m-1)*i+1))%P)*x1)%P+m)%P;
        ans=(ans+1+(a[i]*x2)%P)%P;
    }
    cout<<a[1]<<endl;
    ans=ans*m%P;
    cout<<ans;
    return 0;
}
/*
2
6
2 1 2 2 1 1
4
1 2 1 1
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2

output:

6
18

result:

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