This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = !cnt;
}
return cnt;
}
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";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |