QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#388366 | #8339. Rooted Tree | ucup-team3282# | TL | 1320ms | 3736kb | C++14 | 513b | 2024-04-13 15:00:31 | 2024-04-13 15:00:32 |
Judging History
answer
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mod=1e9+9;
int pow(int a,int b=mod-2){
if(b==0)return 1;
if(b==1)return a;
int ret=pow(a,b>>1);
if(b&1)return (ll)ret*ret%mod*a%mod;
else return (ll)ret*ret%mod;
}
int E=0;
int main(){
int m,k,Kl=1,El=0;
cin>>m>>k;
while(k--){
E=(E+(ll)(El+1)*m)%mod;
El=((ll)El*(Kl-1)+(ll)m*(El+1))%mod*pow(Kl+m-1)%mod;
Kl+=m-1;
}
cout<<E<<endl;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
input:
6 2
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
2 6
output:
600000038
result:
ok 1 number(s): "600000038"
Test #3:
score: 0
Accepted
time: 111ms
memory: 3652kb
input:
83 613210
output:
424200026
result:
ok 1 number(s): "424200026"
Test #4:
score: 0
Accepted
time: 1209ms
memory: 3716kb
input:
48 6713156
output:
198541581
result:
ok 1 number(s): "198541581"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
1 111
output:
6216
result:
ok 1 number(s): "6216"
Test #6:
score: 0
Accepted
time: 1320ms
memory: 3736kb
input:
28 7304152
output:
457266679
result:
ok 1 number(s): "457266679"
Test #7:
score: 0
Accepted
time: 741ms
memory: 3656kb
input:
38 4101162
output:
232117382
result:
ok 1 number(s): "232117382"
Test #8:
score: -100
Time Limit Exceeded
input:
51 9921154