QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#658113 | #8339. Rooted Tree | FXLY_awa# | AC ✓ | 1108ms | 3948kb | C++20 | 2.5kb | 2024-10-19 16:11:29 | 2024-10-19 16:11:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int long long
#define itn int
#define endl '\n'
#define Endl endl
#define ednl endl
#define al(a) (a).begin(),(a).end()
#define all(a) (a).begin()+1,(a).end()
#define debug(x) {cerr<<"ss:"<<x<<endl;}
#define qdebug(x) {cerr<<"ss:";for(auto i:x)cout<<i<<" ";cout<<endl;}
#define lowbit(x) (x&-x)
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define fs first
#define sc second
constexpr long long maxlonglong = 9223372036854775807; //9e18
constexpr int maxint = 2147483647; //2e9
constexpr int INF = 0x7f7f7f7f7f7f7f7f; //2139062143^2
constexpr int M = 1e9 + 7;
constexpr int mod = 998244353;
constexpr int hs = 0x1F351F35; // good hash number.
const double pi = acos(-1.0);
const double eps = 1e-15;
vector<int> input(int n){vector<int> a(n+1);for(int i=1;i<=n;i++)cin>>a[i];return a;}
mt19937_64 rnd(time(0));
const int maxn=1e5+5;
constexpr int N=1231564;
const int p = 1e9+9;
int ksm(int a,int b)
{
int ans=1;
while(b)
{
if(b&1)ans=ans*a%p;
a=a*a%p;
b>>=1;
}
return ans;
}
inline void solve(){
int m,k;cin>>m>>k;
int ans=0,tot=1,con=0;
for(int i=1;i<=k;i++)
{
ans=(ans+(con+1)*m%p)%p;
con=(con*(tot+m-1)+m)%p*ksm(tot+m-1,p-2)%p;
tot+=m-1;
}
cout<<ans%p<<"\n";
}
signed main()
{
//freopen("E:\\work_tool\\document\\data\\input.in", "r", stdin);
//freopen("E:\\work_tool\\document\\data\\output.out", "w", stdout);
ios::sync_with_stdio(false);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0); //关闭同步 如果使用 则不要使用<cstdio>
// cout << fixed << setprecision(10);
int T=1;
// cin>>T;
while(T--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3704kb
input:
6 2
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
2 6
output:
600000038
result:
ok 1 number(s): "600000038"
Test #3:
score: 0
Accepted
time: 68ms
memory: 3924kb
input:
83 613210
output:
424200026
result:
ok 1 number(s): "424200026"
Test #4:
score: 0
Accepted
time: 744ms
memory: 3948kb
input:
48 6713156
output:
198541581
result:
ok 1 number(s): "198541581"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3660kb
input:
1 111
output:
6216
result:
ok 1 number(s): "6216"
Test #6:
score: 0
Accepted
time: 809ms
memory: 3668kb
input:
28 7304152
output:
457266679
result:
ok 1 number(s): "457266679"
Test #7:
score: 0
Accepted
time: 455ms
memory: 3632kb
input:
38 4101162
output:
232117382
result:
ok 1 number(s): "232117382"
Test #8:
score: 0
Accepted
time: 1099ms
memory: 3620kb
input:
51 9921154
output:
340670552
result:
ok 1 number(s): "340670552"
Test #9:
score: 0
Accepted
time: 200ms
memory: 3612kb
input:
79 1801157
output:
620550406
result:
ok 1 number(s): "620550406"
Test #10:
score: 0
Accepted
time: 600ms
memory: 3652kb
input:
22 5417157
output:
457449071
result:
ok 1 number(s): "457449071"
Test #11:
score: 0
Accepted
time: 356ms
memory: 3644kb
input:
25 3210162
output:
36368303
result:
ok 1 number(s): "36368303"
Test #12:
score: 0
Accepted
time: 324ms
memory: 3924kb
input:
67 2919160
output:
935195555
result:
ok 1 number(s): "935195555"
Test #13:
score: 0
Accepted
time: 954ms
memory: 3920kb
input:
77 8613163
output:
482832472
result:
ok 1 number(s): "482832472"
Test #14:
score: 0
Accepted
time: 1107ms
memory: 3676kb
input:
90 10000000
output:
275581651
result:
ok 1 number(s): "275581651"
Test #15:
score: 0
Accepted
time: 1108ms
memory: 3680kb
input:
99 9999999
output:
126087169
result:
ok 1 number(s): "126087169"
Test #16:
score: 0
Accepted
time: 1104ms
memory: 3924kb
input:
100 10000000
output:
451590067
result:
ok 1 number(s): "451590067"
Extra Test:
score: 0
Extra Test Passed