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 <bits/stdc++.h>
using namespace std;
#define dout if(false) cout
void testcase() {
int X, L, N;
cin >> X >> L >> N;
int level = L/(2*N) + 1;
dout << level << endl;
int flips = 0;
int counterPerIter = 1 << level;
int flipPerIter = 2 * counterPerIter - 1;
int iterations = X / counterPerIter;
flips += iterations * flipPerIter;
X = X % counterPerIter;
dout << counterPerIter << endl;
dout << flipPerIter << endl;
while (counterPerIter > 0 && X != 0) {
dout << counterPerIter << endl;
dout << flipPerIter << endl;
dout << flips << endl << endl;
if (counterPerIter <= X) {
X -= counterPerIter;
flips += flipPerIter;
} else {
flips++;
}
counterPerIter = counterPerIter >> 1;
flipPerIter = flipPerIter >> 1;
level--;
}
dout << endl << flips << endl;
int min = (L/(2*N) + 1) * (2*N);
cout << (min | (flips & 1)) << endl;
dout << flips << "\n";
}
signed main() {
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
testcase();
}
}
# | 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... |