#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, l, x, t;
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> t;
while (t--) {
cin >> x >> l >> n;
n<<=1;
ll k = l/n+1, zeros = k+2+(k&1);
--x;
if (k <= 60) x = x&((1LL<<(k+1))-1);
zeros -= __builtin_popcountll(x);
cout << k*n+(zeros&1) << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
444 KB |
Output is correct |
2 |
Correct |
10 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
75 ms |
2244 KB |
Output is correct |
2 |
Correct |
83 ms |
2392 KB |
Output is correct |