QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#714296 | #8339. Rooted Tree | lolte | AC ✓ | 1117ms | 159960kb | C++20 | 748b | 2024-11-05 22:28:32 | 2024-11-05 22:28:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int m,k;
const int mod = 1e9+9 , maxn = 1e7+10;
int kasumi(int x,int y) {
int ans=1,base=x;
while (y) {
if (y&1) ans=(ans*base)%mod;
base=(base*base)%mod;
y>>=1;
}
return ans;
}
int inv(int x) {
return kasumi(x%mod,mod-2);
}
int sum[maxn],qwq[maxn];
signed main(){
ios::sync_with_stdio(false);
//std::cin.tie(nullptr);std::cout.tie(nullptr);
cin>>m>>k;
sum[0]=0;
for (int i=1;i<=k;++i) {
qwq[i]=inv((m-1)*(i-1)+1);
sum[i]=(sum[i-1]*(((m-1)*i+1)%mod)%mod*qwq[i]+m)%mod;
}
int ans=0;
for (int i=1;i<=k;++i) {
ans=(ans+(((((sum[i-1]*qwq[i])+1)%mod)*m)%mod))%mod;
}
cout<<ans%mod<<"\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 5640kb
input:
6 2
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5700kb
input:
2 6
output:
600000038
result:
ok 1 number(s): "600000038"
Test #3:
score: 0
Accepted
time: 71ms
memory: 16136kb
input:
83 613210
output:
424200026
result:
ok 1 number(s): "424200026"
Test #4:
score: 0
Accepted
time: 747ms
memory: 109840kb
input:
48 6713156
output:
198541581
result:
ok 1 number(s): "198541581"
Test #5:
score: 0
Accepted
time: 0ms
memory: 5632kb
input:
1 111
output:
6216
result:
ok 1 number(s): "6216"
Test #6:
score: 0
Accepted
time: 814ms
memory: 120816kb
input:
28 7304152
output:
457266679
result:
ok 1 number(s): "457266679"
Test #7:
score: 0
Accepted
time: 465ms
memory: 71804kb
input:
38 4101162
output:
232117382
result:
ok 1 number(s): "232117382"
Test #8:
score: 0
Accepted
time: 1097ms
memory: 159288kb
input:
51 9921154
output:
340670552
result:
ok 1 number(s): "340670552"
Test #9:
score: 0
Accepted
time: 199ms
memory: 35468kb
input:
79 1801157
output:
620550406
result:
ok 1 number(s): "620550406"
Test #10:
score: 0
Accepted
time: 607ms
memory: 89556kb
input:
22 5417157
output:
457449071
result:
ok 1 number(s): "457449071"
Test #11:
score: 0
Accepted
time: 360ms
memory: 57024kb
input:
25 3210162
output:
36368303
result:
ok 1 number(s): "36368303"
Test #12:
score: 0
Accepted
time: 318ms
memory: 52308kb
input:
67 2919160
output:
935195555
result:
ok 1 number(s): "935195555"
Test #13:
score: 0
Accepted
time: 961ms
memory: 141332kb
input:
77 8613163
output:
482832472
result:
ok 1 number(s): "482832472"
Test #14:
score: 0
Accepted
time: 1117ms
memory: 159908kb
input:
90 10000000
output:
275581651
result:
ok 1 number(s): "275581651"
Test #15:
score: 0
Accepted
time: 1105ms
memory: 159960kb
input:
99 9999999
output:
126087169
result:
ok 1 number(s): "126087169"
Test #16:
score: 0
Accepted
time: 1114ms
memory: 159900kb
input:
100 10000000
output:
451590067
result:
ok 1 number(s): "451590067"
Extra Test:
score: 0
Extra Test Passed