QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#483543 | #8150. XOR Sum | Yuics | AC ✓ | 18ms | 5736kb | C++20 | 1.6kb | 2024-07-18 19:04:43 | 2024-07-18 19:04:43 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
constexpr int N = 207;
constexpr int M = 50;
constexpr int P = 1e9 + 7;
int k, C[M][M], f[M][M][N];
i64 m, n;
int dfs(int digit, int lim, int res) { //现在在 2^digit 位,有 lim 个数达到m的上限,高于等于这个位的还需要的 value 为 res
if (digit < 0) return res == 0;
if (res < 0) return 0;
if ((k / 2) * ((k + 1) / 2) * 2 - 1 < res) return 0;
if (f[digit][lim][res] != -1) return f[digit][lim][res];
int ret = 0;
int add_res = digit == 0 ? 0 : n >> (digit - 1) & 1;
if (m >> digit & 1) {
for (int i = 0; i <= lim;++i)
for (int j = 0; j <= k - lim;++j) {
int val = (i + j) * (k - i - j);
if (val > res) continue;
ret += 1ll * C[lim][i] * C[k - lim][j] % P * dfs(digit - 1, i, (res - val) << 1 | add_res) % P;
ret %= P;
}
} else {
for (int j = 0; j <= k - lim;++j) {
int val = j * (k - j);
if (val > res) continue;
ret += 1ll * C[k - lim][j] * dfs(digit - 1, lim, (res - val) << 1 | add_res) % P;
ret %= P;
}
}
return f[digit][lim][res] = ret;
}
void init() {
for (int i = 0; i <= 18;++i) {
C[i][0] = 1;
for (int j = 1; j <= i;++j)
C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % P;
}
memset(f, -1, sizeof(f));
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
init();
std::cin >> n >> m >> k;
int digit = 0;
i64 tm = m;
while (tm / 2) { ++digit; tm /= 2; }
if (k == 1)
std::cout << (n == 0 ? m + 1 : 0) << "\n";
else
std::cout << dfs(digit, k, n >> digit) << "\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5584kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5732kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5608kb
input:
0 0 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 5584kb
input:
0 0 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 1ms
memory: 5732kb
input:
0 1145141919 2
output:
145141913
result:
ok 1 number(s): "145141913"
Test #6:
score: 0
Accepted
time: 1ms
memory: 5716kb
input:
0 0 18
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 1ms
memory: 5576kb
input:
0 12412414 18
output:
12412415
result:
ok 1 number(s): "12412415"
Test #8:
score: 0
Accepted
time: 3ms
memory: 5652kb
input:
32071009996106 682053093123 12
output:
443207413
result:
ok 1 number(s): "443207413"
Test #9:
score: 0
Accepted
time: 0ms
memory: 5732kb
input:
35533005762427 688386210611 9
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 12ms
memory: 5732kb
input:
35533005762427 688386210611 18
output:
132815685
result:
ok 1 number(s): "132815685"
Test #11:
score: 0
Accepted
time: 18ms
memory: 5604kb
input:
12412412412412 549755813887 18
output:
769139144
result:
ok 1 number(s): "769139144"
Test #12:
score: 0
Accepted
time: 9ms
memory: 5580kb
input:
12412412412412 549755813887 17
output:
256540093
result:
ok 1 number(s): "256540093"
Test #13:
score: 0
Accepted
time: 6ms
memory: 5604kb
input:
12412412412412 549755813887 15
output:
661919152
result:
ok 1 number(s): "661919152"
Test #14:
score: 0
Accepted
time: 0ms
memory: 5672kb
input:
8213830533897 180838478436 12
output:
960275439
result:
ok 1 number(s): "960275439"
Test #15:
score: 0
Accepted
time: 10ms
memory: 5644kb
input:
8213830533897 180838478436 18
output:
794870059
result:
ok 1 number(s): "794870059"
Test #16:
score: 0
Accepted
time: 0ms
memory: 5712kb
input:
56737445336495 759179417237 12
output:
0
result:
ok 1 number(s): "0"
Test #17:
score: 0
Accepted
time: 7ms
memory: 5712kb
input:
56737445336495 759179417237 18
output:
302105482
result:
ok 1 number(s): "302105482"
Test #18:
score: 0
Accepted
time: 3ms
memory: 5584kb
input:
56737445336495 759179417237 15
output:
0
result:
ok 1 number(s): "0"
Test #19:
score: 0
Accepted
time: 0ms
memory: 5736kb
input:
12412412412412 274877906944 18
output:
430003400
result:
ok 1 number(s): "430003400"
Test #20:
score: 0
Accepted
time: 0ms
memory: 5584kb
input:
32412412412412 274877906944 18
output:
657686236
result:
ok 1 number(s): "657686236"
Test #21:
score: 0
Accepted
time: 1ms
memory: 5736kb
input:
562949953421311 549755813887 18
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 0
Accepted
time: 0ms
memory: 5636kb
input:
985162418487295 549755813887 18
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 0ms
memory: 5588kb
input:
985162418487295 962072674303 18
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 16ms
memory: 5668kb
input:
35184372088831 962072674303 18
output:
665848241
result:
ok 1 number(s): "665848241"
Extra Test:
score: 0
Extra Test Passed