QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#668274 | #8339. Rooted Tree | kjhhjki_fan# | TL | 1435ms | 57680kb | C++20 | 433b | 2024-10-23 13:16:27 | 2024-10-23 13:16:31 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define N 10000010
using namespace std;
int m,k;
ll mod=1e9+9,f[N],sum;
inline ll ksm(ll p,ll k){
ll rt=1;
while(k){
if(k&1) rt=rt*p%mod;
p=p*p%mod;
k>>=1;
}
return rt;
}
int main(){
cin>>m>>k;
for(int i=1;i<=k;i++){
f[i]=((i-1)*(m-1)*f[i-1]+m*(f[i-1]+1))%mod*ksm(i*(m-1)+1,mod-2)%mod;
sum+=(f[i-1]+1)*m;
sum%=mod;
}
cout<<sum;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
6 2
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
2 6
output:
600000038
result:
ok 1 number(s): "600000038"
Test #3:
score: 0
Accepted
time: 133ms
memory: 10368kb
input:
83 613210
output:
424200026
result:
ok 1 number(s): "424200026"
Test #4:
score: 0
Accepted
time: 1435ms
memory: 57680kb
input:
48 6713156
output:
198541581
result:
ok 1 number(s): "198541581"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
1 111
output:
6216
result:
ok 1 number(s): "6216"
Test #6:
score: -100
Time Limit Exceeded
input:
28 7304152
output:
457266679