QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#196018 | #6510. Best Carry Player 3 | maoxuyi | WA | 0ms | 3772kb | C++14 | 845b | 2023-10-01 11:01:12 | 2023-10-01 11:01:12 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
inline int qtop (int x) {
int t;
while (x) {
t++;
x >>= 1;
}
return t;
}
int main () {
int T;
scanf("%d", &T);
while (T--) {
LL x, y, k;
scanf("%lld%lld%lld", &x, &y, &k);
int topk = qtop(k);
if (x > y)
swap(x, y);
LL ans = y - x, maxn = (1ll<<topk) - 1;
if (k <= 1) {
printf("%lld\n", ans);
continue;
}
if ((x^y) <= k) {
printf("%lld\n", min(ans, 1ll));
continue;
}else if ((x^y) <= maxn) {
printf("%lld#test\n", min(ans, 2ll));
continue;
}
LL t = ((x&maxn) == maxn ? 1 : (((x>>topk<<topk ^ x ^ maxn) <= k ? 2: 3)));
t += (k == maxn ? 2 : 3) * ((y>>topk) - (x>>topk) - 1);
if (y&maxn)
t += ((y&maxn) <= k ? 1 : 2);
printf("%lld#ok\n", min(ans, t));
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3772kb
input:
8 4 5 0 5 8 3 9 2 6 15 28 5 97 47 8 164 275 38 114514 1919 810 0 1152921504606846975 1
output:
1 2#ok 2#test 2#test 2#test 2#test 2#test 1152921504606846975
result:
wrong output format Expected integer, but "2#ok" found