# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
290826 | gs14004 | CATS (NOI14_cats) | C++17 | 0 ms | 0 KiB |
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 <cstdio>
using lint = long long;
int main(){
int q;
lint x, l, n;
scanf("%d",&q);
while (q--) {
scanf("%lld %lld %lld",&x,&l,&n);
x--; n <<= 1;
lint Q = l / n + 2;
x %= (1ll << min(Q, 61ll));
printf("%lld\n", (Q - 1) * n +__builtin_popcountll(x) % 2);
}
}