QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#522861#8833. Equalizer Ehrmantrautsmosp#AC ✓129ms3732kbC++141.5kb2024-08-17 16:10:452024-08-17 16:10:45

Judging History

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

  • [2024-08-17 16:10:45]
  • 评测
  • 测评结果:AC
  • 用时:129ms
  • 内存:3732kb
  • [2024-08-17 16:10:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i, a, b) for(int i = a; i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
const int MOD = 998244353;

int mod_pow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1) {
            res = (res * a) % MOD;
        }

        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

int mod_div(int a, int b) {
    return (a * mod_pow(b, MOD - 2)) % MOD;
}

bool check(vector<int> &a, vector<int> &b) {
    rep(i, 0, a.size()) {
        rep(j, 0, a.size()) {
            if (min(a[i], b[j]) != min(a[j], b[i])) {
                return false;
            }
        }
    }
    return true;
}

int solve(int n, int m, int i, vector<int> &a, vector<int> &b) {
    if (i == n) {
        return check(a, b);
    }

    int res = 0;
    rep(j, 1, m + 1) {
        rep(k, 1, m + 1) {
            a[i] = j;
            b[i] = k;
            res = (res + solve(n, m, i + 1, a, b)) % MOD;
        }
    }
    return res;
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);

    int n, m;
    cin >> n >> m;

    // vector<int> a(n), b(n);
    // cout << (solve(n, m, 0, a, b)) << endl;

    int res = 0;
    rep(i, 1, m + 1) {
        res = (res + mod_pow(m, n) - mod_pow(i, n) + MOD) % MOD;
    }
    res = (res * 2ll) % MOD;
    res = (res + mod_pow(m, n)) % MOD;
    cout << res << endl;

    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

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

input:

2 2

output:

10

result:

ok 1 number(s): "10"

Test #3:

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

input:

69 42

output:

608932821

result:

ok 1 number(s): "608932821"

Test #4:

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

input:

102 156

output:

748401290

result:

ok 1 number(s): "748401290"

Test #5:

score: 0
Accepted
time: 3ms
memory: 3732kb

input:

4646 95641

output:

89806680

result:

ok 1 number(s): "89806680"

Test #6:

score: 0
Accepted
time: 20ms
memory: 3604kb

input:

42849 215151

output:

242217237

result:

ok 1 number(s): "242217237"

Test #7:

score: 0
Accepted
time: 106ms
memory: 3668kb

input:

786416 794116

output:

472898000

result:

ok 1 number(s): "472898000"

Test #8:

score: 0
Accepted
time: 104ms
memory: 3580kb

input:

963852 789456

output:

353211048

result:

ok 1 number(s): "353211048"

Test #9:

score: 0
Accepted
time: 53ms
memory: 3604kb

input:

696969 424242

output:

787990158

result:

ok 1 number(s): "787990158"

Test #10:

score: 0
Accepted
time: 13ms
memory: 3684kb

input:

1000000 123456

output:

533491028

result:

ok 1 number(s): "533491028"

Test #11:

score: 0
Accepted
time: 129ms
memory: 3596kb

input:

1000000 1000000

output:

572586375

result:

ok 1 number(s): "572586375"

Test #12:

score: 0
Accepted
time: 102ms
memory: 3724kb

input:

123456 1000000

output:

486967129

result:

ok 1 number(s): "486967129"

Test #13:

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

input:

789456 1

output:

1

result:

ok 1 number(s): "1"

Test #14:

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

input:

852516 2

output:

148946358

result:

ok 1 number(s): "148946358"

Test #15:

score: 0
Accepted
time: 5ms
memory: 3728kb

input:

1 953646

output:

40087733

result:

ok 1 number(s): "40087733"

Test #16:

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

input:

3 7686

output:

278212472

result:

ok 1 number(s): "278212472"

Extra Test:

score: 0
Extra Test Passed