/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 3ms 772.0 KiB
#3 Accepted 3ms 540.0 KiB
#4 Accepted 3ms 540.0 KiB
#5 Accepted 17ms 904.0 KiB
#6 Accepted 5ms 540.0 KiB
#7 Accepted 24ms 1.02 MiB
#8 Accepted 22ms 1.484 MiB

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-05-06 21:17:34
Judged By
Score
100
Total Time
24ms
Peak Memory
1.484 MiB