QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#388357 | #8339. Rooted Tree | ucup-team3282# | TL | 186ms | 3588kb | C++14 | 594b | 2024-04-13 14:56:14 | 2024-04-13 14:56:14 |
Judging History
answer
#include<iostream>
#include<algorithm>
using namespace std;
long long mod=1e9+9;
long long pow(long long a,long long b=mod-2){
if(b==0)return 1;
if(b==1)return a;
long long ret=pow(a,b>>1);
if(b&1)return ret*ret%mod*a%mod;
else return ret*ret%mod;
}
long long E=0;
int main(){
// cout<<24*pow(3)%mod<<endl;
long long m,k,Kl=1,El=0;
cin>>m>>k;
while(k--){
// cout<<El*6%mod<<" "<<E*3%mod<<"?"<<Kl<<endl;
E=(E+(El+1)*m)%mod;
El=(El*(Kl-1)+m*(El+1))%mod*pow(Kl+m-1)%mod;
Kl+=m-1;
}
cout<<E<<endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
input:
6 2
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
2 6
output:
600000038
result:
ok 1 number(s): "600000038"
Test #3:
score: 0
Accepted
time: 186ms
memory: 3536kb
input:
83 613210
output:
424200026
result:
ok 1 number(s): "424200026"
Test #4:
score: -100
Time Limit Exceeded
input:
48 6713156