QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#399345#6736. Alice and BobKidding_MaCompile Error//C++141.1kb2024-04-26 10:57:412024-04-26 10:57:43

Judging History

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

  • [2024-04-26 10:57:43]
  • 评测
  • [2024-04-26 10:57:41]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;
using i64 = long long;

constexpr int P = 998244353;
i64 *fac, *ifac;

i64 power(i64 a, i64 b, int p = P) {
    i64 res = 1;
    for (; b; b >>= 1, a = a * a % p) {
        if (b & 1) {
            res = res * a % p;
        }
    }
    return res;
}
   
i64 inv(i64 x) {
    return power(x, P - 2, P);
}
  
void init(int N) {
    fac = new i64 [N + 1];
    ifac = new i64 [N + 1];
    fac[0] = 1;
    for (int i = 1; i <= N; i++) {
        fac[i] = fac[i - 1] * i % P;
    }
    ifac[N] = inv(fac[N]);
    for (int i = N - 1; i >= 0; i--) {
        ifac[i] = ifac[i + 1] * (i + 1) % P;
    }
}
  
i64 C(int n, int m) {
    if (m < 0 || m > n || n < 0) {
        return 0;
    }
    return fac[n] * ifac[m] % P * ifac[n - m] % P;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    init(1E7);

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        ans = (ans + C(n - i, i - 1) * C(n - i, n - i) % P) % P;
    }
    cout << ans << '\n';

    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:52:9: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   52 |         ans = (ans + C(n - i, i - 1) * C(n - i, n - i) % P) % P;
      |         ^~~
      |         abs
answer.code:54:13: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   54 |     cout << ans << '\n';
      |             ^~~
      |             abs