#include <iostream>
#include <stack>
long long int popcount(long long int x)
{
long long int cnt = 0;
for (; x > 0; x >>= 1)
{
if (x & 1)
++cnt;
}
return (cnt % 2);
}
int main()
{
int q;
std::cin >> q;
while (q--)
{
long long int x, l, n;
std::cin >> x >> l >> n;
--x;
n *= 2;
long long int dis = ((l / n) + 1) * n;
n /= 2;
long long int period = (l + 2 * n - 1) / (2 * n);
if (period <= 60)
{
period = 2LL << period;
x %= period;
}
std::cout << dis + popcount(x) << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
500 KB |
Output is correct |
3 |
Correct |
2 ms |
500 KB |
Output is correct |
4 |
Correct |
2 ms |
500 KB |
Output is correct |
5 |
Correct |
2 ms |
524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
568 KB |
Output is correct |
2 |
Correct |
2 ms |
568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
596 KB |
Output is correct |
2 |
Correct |
3 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
596 KB |
Output is correct |
2 |
Correct |
5 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
660 KB |
Output is correct |
2 |
Correct |
39 ms |
1044 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
351 ms |
2816 KB |
Output is correct |
2 |
Correct |
413 ms |
3576 KB |
Output is correct |