QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#190820 | #5586. Digits of Unity | hrjames1526 | AC ✓ | 338ms | 81568kb | C++20 | 2.3kb | 2023-09-29 14:36:02 | 2023-09-29 14:36:02 |
Judging History
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 = 5e6 + 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 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 MUL(int a, int b) {
return 1LL * a * b % 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 = 1; 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]);
}
res = MUL(res, frac[n]);
cout << res;
return 0;
}
/*
*/
詳細信息
Test #1:
score: 100
Accepted
time: 329ms
memory: 81468kb
input:
2 2 10
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 319ms
memory: 81504kb
input:
3 4 14
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 331ms
memory: 81408kb
input:
2 1 100000
output:
910073387
result:
ok single line: '910073387'
Test #4:
score: 0
Accepted
time: 322ms
memory: 81440kb
input:
30 6 136665
output:
552360422
result:
ok single line: '552360422'
Test #5:
score: 0
Accepted
time: 308ms
memory: 81568kb
input:
178 6 51500
output:
788418998
result:
ok single line: '788418998'
Test #6:
score: 0
Accepted
time: 331ms
memory: 81440kb
input:
445 4 91471
output:
322733059
result:
ok single line: '322733059'
Test #7:
score: 0
Accepted
time: 321ms
memory: 81380kb
input:
23634 10 299334
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 319ms
memory: 77240kb
input:
242554 5 287650
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 328ms
memory: 81320kb
input:
1 1 1
output:
1
result:
ok single line: '1'
Test #10:
score: 0
Accepted
time: 329ms
memory: 81344kb
input:
1 3 7
output:
1
result:
ok single line: '1'
Test #11:
score: 0
Accepted
time: 318ms
memory: 81520kb
input:
1 1 7
output:
7
result:
ok single line: '7'
Test #12:
score: 0
Accepted
time: 314ms
memory: 81344kb
input:
500000 500000 5000000
output:
0
result:
ok single line: '0'
Test #13:
score: 0
Accepted
time: 327ms
memory: 77380kb
input:
250000 1 5000000
output:
578914111
result:
ok single line: '578914111'
Test #14:
score: 0
Accepted
time: 318ms
memory: 81532kb
input:
4096 6 449389
output:
129538870
result:
ok single line: '129538870'
Test #15:
score: 0
Accepted
time: 319ms
memory: 77416kb
input:
50 2 50
output:
0
result:
ok single line: '0'
Test #16:
score: 0
Accepted
time: 323ms
memory: 81496kb
input:
250000 65 5000000
output:
0
result:
ok single line: '0'
Test #17:
score: 0
Accepted
time: 338ms
memory: 81504kb
input:
1 1 5000000
output:
5000000
result:
ok single line: '5000000'
Test #18:
score: 0
Accepted
time: 328ms
memory: 81532kb
input:
2 17 5000000
output:
7104108
result:
ok single line: '7104108'