Submission #51676

#TimeUsernameProblemLanguageResultExecution timeMemory
51676KubalionzzaleCATS (NOI14_cats)C++14
25 / 25
413 ms3576 KiB
#include <iostream> #include <stack> long long int popcount(long long int x) { long long int cnt = 0; for (; x > 0; x >>= 1) { if (x & 1) ++cnt; } return (cnt % 2); } int main() { int q; std::cin >> q; while (q--) { long long int x, l, n; std::cin >> x >> l >> n; --x; n *= 2; long long int dis = ((l / n) + 1) * n; n /= 2; long long int period = (l + 2 * n - 1) / (2 * n); if (period <= 60) { period = 2LL << period; x %= period; } std::cout << dis + popcount(x) << "\n"; } }
#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...