QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#683412 | #8339. Rooted Tree | goblin_team# | TL | 1211ms | 121628kb | C++14 | 776b | 2024-10-27 20:53:39 | 2024-10-27 20:53:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000009;
ll m,k,sqr;
ll qpow(ll b, ll x){
if(x==0) return 1;
ll tmp = qpow(b,x/2);
if(x&1) return tmp*tmp%mod*b%mod;
else return tmp*tmp%mod;
}
ll inv(ll x){
return qpow(x%mod, mod-2);
}
ll invv[10000005];
ll calc(ll i){
return sqr*invv[i]%mod;
}
ll diff[10000005];
int main(){
// m=100; k=1e7;
cin>>m>>k;
diff[1] = m;
sqr = m*m%mod;
for(int i=2; i<=k; ++i) invv[i] = inv(ll(i-1)*(m-1)+1);
for(int i=2; i<=k; ++i){
diff[i] = (diff[i-1] + calc(i))%mod;
}
ll g = 0;
for(int i=1; i<=k; ++i) {
g+=diff[i];
g%=mod;
}
cout<<g<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5664kb
input:
6 2
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5636kb
input:
2 6
output:
600000038
result:
ok 1 number(s): "600000038"
Test #3:
score: 0
Accepted
time: 101ms
memory: 16140kb
input:
83 613210
output:
424200026
result:
ok 1 number(s): "424200026"
Test #4:
score: 0
Accepted
time: 1122ms
memory: 110092kb
input:
48 6713156
output:
198541581
result:
ok 1 number(s): "198541581"
Test #5:
score: 0
Accepted
time: 0ms
memory: 5736kb
input:
1 111
output:
6216
result:
ok 1 number(s): "6216"
Test #6:
score: 0
Accepted
time: 1211ms
memory: 121628kb
input:
28 7304152
output:
457266679
result:
ok 1 number(s): "457266679"
Test #7:
score: 0
Accepted
time: 688ms
memory: 71516kb
input:
38 4101162
output:
232117382
result:
ok 1 number(s): "232117382"
Test #8:
score: -100
Time Limit Exceeded
input:
51 9921154