QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#686715 | #8339. Rooted Tree | ucup-team1412 | WA | 0ms | 3556kb | C++14 | 708b | 2024-10-29 15:17:58 | 2024-10-29 15:17:59 |
Judging History
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'