Submission #155962

#TimeUsernameProblemLanguageResultExecution timeMemory
155962MinnakhmetovCATS (NOI14_cats)C++14
25 / 25
95 ms8056 KiB
// #include <bits/stdc++.h> // #define ll long long // #define all(aaa) aaa.begin(), aaa.end() // using namespace std; // int f(ll x, ll y) { // if (x == 0) // return 0; // if (x < y / 2) // return f(x, y / 2); // return f(x - y / 2, y / 2) ^ 1; // } // signed main() { // ios_base::sync_with_stdio(0); // cin.tie(0); // int q; // cin >> q; // while (q--) { // ll x, l, n; // cin >> x >> l >> n; // x--; // cout << x << "\n"; // ll ans = 2 * (l / (n << 1) + 1) * n; // cout << (ans ^ f(x, 1ll << 61)) << "\n"; // } // return 0; // } #include <bits/stdc++.h> #define ll long long #define all(aaa) aaa.begin(), aaa.end() using namespace std; struct MyStack { vector<int> v; int flip = 0; void push(int x) { v.push_back(x); } int pop() { if (!v.empty()) { int x = v.back(); v.pop_back(); return x; } return flip; } int top() { return v.empty() ? flip : v.back(); } void add() { push(pop() + pop()); } }; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int q; cin >> q; while (q--) { ll x, l, n; cin >> x >> l >> n; ll h = l / (n << 1) + 1; ll ans = 2 * h * n; x--; if (h <= 62) x %= (1ll << (h + 1)); while (x > 0) { ans ^= (x & 1); x >>= 1; } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...