QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#303602 | #6510. Best Carry Player 3 | lucas110550 | WA | 0ms | 3616kb | C++14 | 1.1kb | 2024-01-12 19:55:56 | 2024-01-12 19:55:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
long long x, y, k;
int T;
int main( ) {
scanf("%d", &T);
while (T --) {
scanf("%lld %lld %lld", &x, &y, &k);
if (k == 0)
printf("%lld\n", abs(x - y));
else {
if (x > y)
swap(x, y);
int cur = -1;
for (int i = 60; i >= 0; i --)
if (((x >> i) & 1) != ((y >> i) & 1)) {
cur = i;
break;
}
if (cur == -1)
printf("0\n");
else {
long long o = 1;
int p = 0;
long long K = k;
while (K)
K >>= 1, o <<= 1, ++ p;
if (cur <= p) {
long long z = x ^ y;
if (z <= k)
printf("1\n");
else
printf("2\n");
} else {
long long A = (y >> p);
long long B = ((x >> p) + 1);
long long tmp = 1, res = o - 1 - x % o;
if (res) {
if (res <= k)
++ tmp;
else
tmp += 2;
}
tmp = min(tmp, (B << p) - x) + (A - B) * (2 + (k != o - 1));
res = y % o;
if (res == 0)
printf("%lld\n", tmp);
else if (res <= k)
printf("%lld\n", tmp + 1);
else
printf("%lld\n", tmp + 2);
}
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3616kb
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 2 5 11 6 331 1152921504606846975
result:
wrong answer 3rd numbers differ - expected: '3', found: '2'