QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#639105 | #8339. Rooted Tree | YinyuDream | WA | 0ms | 3564kb | C++20 | 649b | 2024-10-13 17:57:18 | 2024-10-13 17:57:22 |
Judging History
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'