結果

問題 No.1930 XOR of Two Range
ユーザー tonyu0tonyu0
提出日時 2022-05-08 17:27:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,157 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 97,492 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 14:21:53
合計ジャッジ時間 1,626 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 30 ms
4,376 KB
testcase_02 AC 42 ms
4,380 KB
testcase_03 AC 42 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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