QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#190802#5586. Digits of Unityhrjames1526WA 299ms81404kbC++202.2kb2023-09-29 14:26:482023-09-29 14:26:49

Judging History

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

  • [2023-09-29 14:26:49]
  • 评测
  • 测评结果:WA
  • 用时:299ms
  • 内存:81404kb
  • [2023-09-29 14:26:48]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define file ""

#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()

#define getbit(x, i) (((x) >> (i)) & 1)
#define bit(x) (1LL << (x))
#define popcount __builtin_popcountll

mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) {
    return l + rd() % (r - l + 1);
}

const int N = 1e6 + 5;
const int mod = 998244353;
const int lg = 23; // lg + 1
const int oo = 1e9;
const long long ooo = 1e18;

template<class X, class Y> bool mini(X &a, Y b) {
    return a > b ? (a = b, true) : false;
}
template<class X, class Y> bool maxi(X &a, Y b) {
    return a < b ? (a = b, true) : false;
}
void add(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
    if (a < 0) a += mod;
}

int n, k, m;
int f[1 << lg];
int pw2[1 << lg];

int frac[1 << lg], inv[1 << lg];
int pw(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = 1LL * x * x % mod)
        if (y & 1)
            res = 1LL * res * x % mod;
    return res;
}
void pre() {
    int n = 5e6;
    frac[0] = 1;
    for (int i = 1; i <= n; ++i) frac[i] = 1LL * frac[i - 1] * i % mod;
    inv[n] = pw(frac[n], mod - 2);
    for (int i = n; i >= 1; --i) inv[i - 1] = 1LL * inv[i] * i % mod;
}
int nCk(int n, int k) {
    return k > n ? 0 : 1LL * frac[n] * inv[k] % mod * inv[n - k] % mod;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    // freopen(file".inp", "r", stdin);
    // freopen(file".out", "w", stdout);

    pre();

    cin >> n >> k >> m;

    for (int i = 0; i <= m; ++i) f[i] = 1;

    for (int i = 0; i < lg; ++i) for (int mask = 0; mask < bit(lg); ++mask) if (!getbit(mask, i)) {
        add(f[mask], f[mask ^ bit(i)]);
    }

    for (int mask = 0; mask < bit(lg); ++mask) {
        f[mask] = nCk(f[mask], n);
    }

    for (int i = 0; i < lg; ++i) for (int mask = 0; mask < bit(lg); ++mask) if (!getbit(mask, i)) {
        add(f[mask], -f[mask ^ bit(i)]);
    }

    int res = 0;
    for (int mask = 0; mask <= m; ++mask) if (popcount(mask) >= k) {
        add(res, f[mask]);
    }

    cout << (res * 2) % mod;

    return 0;
}

/*

*/

详细

Test #1:

score: 100
Accepted
time: 297ms
memory: 77440kb

input:

2 2 10

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 287ms
memory: 77420kb

input:

3 4 14

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 299ms
memory: 81376kb

input:

2 1 100000

output:

910073387

result:

ok single line: '910073387'

Test #4:

score: -100
Wrong Answer
time: 290ms
memory: 81404kb

input:

30 6 136665

output:

66231263

result:

wrong answer 1st lines differ - expected: '552360422', found: '66231263'