# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125413 | Touubs | CATS (NOI14_cats) | C++17 | 663 ms | 2360 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 <bits/stdc++.h>
using namespace std;
#define dout if(false) cout
#define int unsigned long long
void testcase() {
int X, L, N;
cin >> X >> L >> N;
int originalX = X;
X--;
int level = L/(2*N) + 1;
dout << "level: " << level << endl;
int counterPerIter = (2 << level) | -1ull;
int flipPerIter = 2 * counterPerIter - 1;
int iterations = X / counterPerIter;
int flips = 0;
X = X % counterPerIter;
dout << "counterPerIter: " << counterPerIter << endl;
dout << "flipPerIter: " << flipPerIter << endl;
while (X > 0) {
//cout << "X: " << X << ", flips: " << flips << " | ";
if ((X & 1) == 1) flips = flips ^ 1;
X = X >> 1;
}
dout << endl << "end. flips: " << flips << endl;
int min = (L/(2*N) + 1) * (2*N);
cout << ((min ^ ((flips) & 1))) << endl;
}
signed main() {
int Q;
cin >> Q;
for (int i = 0; i < Q; i++) {
testcase();
}
}
Compilation message (stderr)
# | 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... |