QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#459394#8833. Equalizer Ehrmantrautucup-team3734#AC ✓156ms3744kbC++231.6kb2024-06-30 03:09:312024-06-30 03:09:31

Judging History

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

  • [2024-06-30 03:09:31]
  • 评测
  • 测评结果:AC
  • 用时:156ms
  • 内存:3744kb
  • [2024-06-30 03:09:31]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

#define all(x) (x).begin(), (x).end()

const int mod = 998244353;

int add(int x) {
  return x;
}

template<typename... T>
int add(int x, T... y) {
  x += add(y...);
  if (x >= mod)
    x -= mod;
  return x;
}

template<typename... T>
int udd(int &x, T... y) {
  return x = add(x, y...);
}

template<typename... T>
int sub(int x, T... y) {
  return add(x, mod - add(y...));
}

int mul(int x) {
  return x;
}

template<typename... T>
int mul(int x, T... y) {
  return 1ll * x * mul(y...) % mod;
}

int bin(int x, int to) {
  int y = 1;
  while (to) {
    if (to & 1) {
      y = mul(x, y);
    }
    to >>= 1;
    x = mul(x, x);
  }
  return y;
}

int inv(int x) {
  assert(x != 0);
  return bin(x, mod - 2);
}

const int M = 100300;

int fact[M], ifact[M];

int binom(int n, int k) {
  if (n < 0 || k < 0 || n < k)
    return 0;
  return mul(fact[n], ifact[n - k], ifact[k]);
}

void precalc() {
  fact[0] = 1;
  for (int i = 1; i < M; ++i) {
    fact[i] = mul(i, fact[i - 1]);
  }
  for (int i = 0; i < M; ++i)
    ifact[i] = inv(fact[i]);
}

int main() {
  ios_base::sync_with_stdio(false);

//  int t;
//  cin >> t;
//  while (t--) {
//
//  }

  int n, m;
  cin >> n >> m;
  int ans = 0;
  udd(ans, bin(m, n));

  for (int i = 1; i <= m; ++i) {
    int x = i;
    int y = m - i;
    int cnt = sub(bin(x + y, n), bin(x, n));
    udd(ans, mul(2, cnt));
  }

  cout << ans << "\n";

  return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

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

input:

2 2

output:

10

result:

ok 1 number(s): "10"

Test #3:

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

input:

69 42

output:

608932821

result:

ok 1 number(s): "608932821"

Test #4:

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

input:

102 156

output:

748401290

result:

ok 1 number(s): "748401290"

Test #5:

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

input:

4646 95641

output:

89806680

result:

ok 1 number(s): "89806680"

Test #6:

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

input:

42849 215151

output:

242217237

result:

ok 1 number(s): "242217237"

Test #7:

score: 0
Accepted
time: 115ms
memory: 3676kb

input:

786416 794116

output:

472898000

result:

ok 1 number(s): "472898000"

Test #8:

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

input:

963852 789456

output:

353211048

result:

ok 1 number(s): "353211048"

Test #9:

score: 0
Accepted
time: 62ms
memory: 3660kb

input:

696969 424242

output:

787990158

result:

ok 1 number(s): "787990158"

Test #10:

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

input:

1000000 123456

output:

533491028

result:

ok 1 number(s): "533491028"

Test #11:

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

input:

1000000 1000000

output:

572586375

result:

ok 1 number(s): "572586375"

Test #12:

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

input:

123456 1000000

output:

486967129

result:

ok 1 number(s): "486967129"

Test #13:

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

input:

789456 1

output:

1

result:

ok 1 number(s): "1"

Test #14:

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

input:

852516 2

output:

148946358

result:

ok 1 number(s): "148946358"

Test #15:

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

input:

1 953646

output:

40087733

result:

ok 1 number(s): "40087733"

Test #16:

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

input:

3 7686

output:

278212472

result:

ok 1 number(s): "278212472"

Extra Test:

score: 0
Extra Test Passed