QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468493#8339. Rooted Treereal_sigma_team#TL 175ms3592kbC++201.5kb2024-07-08 21:07:332024-07-08 21:07:33

Judging History

你现在查看的是最新测评结果

  • [2024-07-08 21:07:33]
  • 评测
  • 测评结果:TL
  • 用时:175ms
  • 内存:3592kb
  • [2024-07-08 21:07:33]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>


#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,bmi2,fma,popcnt")


#ifdef lisie_bimbi
#define debug(x) cout << #x << " : " << x << endl;
#else
#define endl '\n'
#endif

//#define int long long
#define inf 1000000000000000000
#define double long double
typedef long long ll;

int mod = 1000000009;

int add(int a, int b) {
    return a + b >= mod ? a + b - mod : a + b;
}

int sub(int a, int b) {
    return a >= b ? a - b : a + mod - b;
}

int mul(int a, int b) {
    return (long long)a * b % mod;
}

int binpow(int a, int b){
    if(b == 0){
        return 1;
    }
    int ans = binpow(a, b / 2);
    ans = mul(ans, ans);
    if(b % 2 == 1){
        ans = mul(ans, a);
    }
    return ans;
}

int del(int a, int b){
    return mul(a, binpow(b, mod - 2));
}

signed main() {
#ifdef lisie_bimbi
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#endif
    int m, k;
    cin >> m >> k;
    int d = 0;
    int cnt = 1;
    int ans = 0;
    for(int i = 0; i < k; i++){
        ans = add(ans, mul(m, add(d, 1)));
        d = del(add(mul(sub(cnt, 1), d), mul(m, add(d, 1))), sub(add(cnt, m), 1));
        cnt = add(cnt, m - 1);
    }
    cout << ans;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3588kb

input:

6 2

output:

18

result:

ok 1 number(s): "18"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

2 6

output:

600000038

result:

ok 1 number(s): "600000038"

Test #3:

score: 0
Accepted
time: 175ms
memory: 3588kb

input:

83 613210

output:

424200026

result:

ok 1 number(s): "424200026"

Test #4:

score: -100
Time Limit Exceeded

input:

48 6713156

output:


result: