Accepted
Code
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
for (int tc = 1; tc <= tt; tc++) {
int n;
cin >> n;
int ans = 0;
while (n > 3) {
int x = 4;
while (x * 2 <= n) x *= 2;
n -= x;
if (n % 2 == 0) {
ans += x;
}
}
while (n > 0) {
ans ^= n;
n--;
}
cout << ans << '\n';
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1009 XOR Love
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-05-06 21:17:34
- Judged At
- 2024-11-11 03:31:27
- Judged By
- Score
- 100
- Total Time
- 37ms
- Peak Memory
- 1.402 MiB