QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#710493 | #8339. Rooted Tree | New_Folder# | WA | 165ms | 214824kb | C++20 | 886b | 2024-11-04 20:05:23 | 2024-11-04 20:05:23 |
Judging History
answer
#pragma GCC optimize(2)
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod=1e9+9;
ll a[10000001];
ll pre[10000001];
ll sv[10000001];
ll inv[10000001];
ll fastpow(ll base,ll po){
ll ans=1;
while(po){
if(po&1){
ans=ans*base%mod;
}
base=base*base%mod;
po>>=1;
}
return ans;
}
void solve(){
ll m,k;
cin>>m>>k;
pre[0]=1;
for(int i=1;i<=k;i++){
a[i]=i*(m-1)+1;
pre[i]=pre[i-1]*a[i]%mod;
}
sv[k]=fastpow(pre[k],mod-2);
for(int i=k-1;i>=0;i--){
sv[i]=sv[i+1]*a[i+1]%mod;
}
for(int i=1;i<=k;i++){
inv[i]=sv[i]*pre[i-1]%mod;
}
ll ans=m*k;
ll temp=0;
for(int i=1;i<=k-1;i++){
temp+=inv[i]*(k-i)%mod;
temp%=mod;
}
temp=temp*m%mod*m%mod;
ans=ans+temp%mod;
cout<<ans;
}
int main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 9852kb
input:
6 2
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 0ms
memory: 9780kb
input:
2 6
output:
600000038
result:
ok 1 number(s): "600000038"
Test #3:
score: 0
Accepted
time: 18ms
memory: 31428kb
input:
83 613210
output:
424200026
result:
ok 1 number(s): "424200026"
Test #4:
score: -100
Wrong Answer
time: 165ms
memory: 214824kb
input:
48 6713156
output:
1198541590
result:
wrong answer 1st numbers differ - expected: '198541581', found: '1198541590'