QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695234#8833. Equalizer EhrmantrautIllusionaryWhiteTraveler#AC ✓74ms11524kbC++20967b2024-10-31 19:34:392024-10-31 19:34:40

Judging History

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

  • [2024-10-31 19:34:40]
  • 评测
  • 测评结果:AC
  • 用时:74ms
  • 内存:11524kb
  • [2024-10-31 19:34:39]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1000000 + 5;
const int P = 998244353;

int power(int a, int n) {
    int ans = 1;
    while (n) {
        if (n & 1) ans = 1ll * ans * a % P;
        a = 1ll * a * a % P; n >>= 1;
    }
    return ans;
}

int fac[MAX_N], ifac[MAX_N];

void init() {
    fac[0] = 1;
    for (int i = 1; i < MAX_N; i ++) fac[i] = 1ll * fac[i - 1] * i % P;
    ifac[MAX_N - 1] = power(fac[MAX_N - 1], P - 2);
    for (int i = MAX_N - 2; i >= 0; i --) ifac[i] = (i + 1ll) * ifac[i + 1] % P;
}

inline int Comb(int n, int m) {
    if (n < m || m < 0) return 0;
    return 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;
}

int main() {
    init();
    int N, M;
    cin >> N >> M;
    int ans = 0, x = power(M, N);
    for (int i = 1; i < M; i ++) {
        ans = (1ll * ans + x - power(i, N) + P) % P;
    }
    ans = (2ll * ans + x + P) % P;
    cout << ans << '\n';
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 10ms
memory: 11504kb

input:

1 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: 0
Accepted
time: 10ms
memory: 11372kb

input:

2 2

output:

10

result:

ok 1 number(s): "10"

Test #3:

score: 0
Accepted
time: 10ms
memory: 11436kb

input:

69 42

output:

608932821

result:

ok 1 number(s): "608932821"

Test #4:

score: 0
Accepted
time: 10ms
memory: 11312kb

input:

102 156

output:

748401290

result:

ok 1 number(s): "748401290"

Test #5:

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

input:

4646 95641

output:

89806680

result:

ok 1 number(s): "89806680"

Test #6:

score: 0
Accepted
time: 21ms
memory: 11524kb

input:

42849 215151

output:

242217237

result:

ok 1 number(s): "242217237"

Test #7:

score: 0
Accepted
time: 65ms
memory: 11444kb

input:

786416 794116

output:

472898000

result:

ok 1 number(s): "472898000"

Test #8:

score: 0
Accepted
time: 64ms
memory: 11504kb

input:

963852 789456

output:

353211048

result:

ok 1 number(s): "353211048"

Test #9:

score: 0
Accepted
time: 34ms
memory: 11504kb

input:

696969 424242

output:

787990158

result:

ok 1 number(s): "787990158"

Test #10:

score: 0
Accepted
time: 11ms
memory: 11440kb

input:

1000000 123456

output:

533491028

result:

ok 1 number(s): "533491028"

Test #11:

score: 0
Accepted
time: 74ms
memory: 11324kb

input:

1000000 1000000

output:

572586375

result:

ok 1 number(s): "572586375"

Test #12:

score: 0
Accepted
time: 67ms
memory: 11440kb

input:

123456 1000000

output:

486967129

result:

ok 1 number(s): "486967129"

Test #13:

score: 0
Accepted
time: 7ms
memory: 11524kb

input:

789456 1

output:

1

result:

ok 1 number(s): "1"

Test #14:

score: 0
Accepted
time: 10ms
memory: 11504kb

input:

852516 2

output:

148946358

result:

ok 1 number(s): "148946358"

Test #15:

score: 0
Accepted
time: 15ms
memory: 11444kb

input:

1 953646

output:

40087733

result:

ok 1 number(s): "40087733"

Test #16:

score: 0
Accepted
time: 10ms
memory: 11440kb

input:

3 7686

output:

278212472

result:

ok 1 number(s): "278212472"

Extra Test:

score: 0
Extra Test Passed