QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#617519 | #8339. Rooted Tree | lzy | TL | 138ms | 3576kb | C++14 | 670b | 2024-10-06 15:59:06 | 2024-10-06 15:59:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
typedef long long ll;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int a[N];
int mod=1e9+9;
int qpow(ll a,ll b){
ll res=1;
while(b){
if(b&1)res=res*a%mod;
a=a*a%mod;
b>>=1;
}
return res;
}
void solve() {
int n,k;
cin>>n>>k;
ll av,sum=0;
ll leave=0;int siz1=1,siz2=1;
for(int i=1;i<=k;i++){
av=leave*qpow(siz2,mod-2)%mod;
sum=(sum+n*(av+1)%mod)%mod;
leave=(leave+n*(av+1)%mod-av+mod)%mod;
siz1=(siz1+n)%mod;
siz2=(siz2+n-1)%mod;
}
cout<<sum<<"\n";
}
signed main() {
IOS;
int t = 1;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
6 2
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
2 6
output:
600000038
result:
ok 1 number(s): "600000038"
Test #3:
score: 0
Accepted
time: 138ms
memory: 3548kb
input:
83 613210
output:
424200026
result:
ok 1 number(s): "424200026"
Test #4:
score: -100
Time Limit Exceeded
input:
48 6713156
output:
198541581