結果

問題 No.1930 XOR of Two Range
ユーザー tonyu0
提出日時 2022-05-08 17:27:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 1,157 bytes
コンパイル時間 1,038 ms
コンパイル使用メモリ 95,540 KB
最終ジャッジ日時 2025-01-29 05:08:02
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)
#define all(a) a.begin(), a.end()
template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> &a) {
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? " " : "") << a[i];
  return os << '\n';
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (T &x : a) { is >> x; }
  return is;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    ll l, r;
    cin >> l >> r;
    // ll ans = 0;
    // for (ll i = l * 2; i <= l + r; i += 4) {
    //   ans ^= i;
    //   if (i + 1 <= l + r) ans ^= i + 1;
    // }
    // cout << ans << '\n';
    ll a = (r - l) / 4 + 1;
    if ((l + r) % 2) {
      cout << a % 2 << '\n';
    } else {
      if ((r - l) % 4 == 0) {
        cout << ((a - 1) % 2 ^ (l + r)) << '\n';
      } else {
        cout << a % 2 << '\n';
      }
    }
  }
  return 0;
}
0