Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int T, N, a = 0, b = 0, ax, bx;
- cin >> T;
- for (int i = 0; i < T; i++) {
- cin >> N;
- a = 0; b = 0;
- for (int i = 1; i <= N; i++) {
- ax = a^i;
- bx = b^i;
- if (ax + b >= a+ bx) {
- a = ax;
- } else b = bx;
- }
- cout << a+b << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment