結果

問題 No.1930 XOR of Two Range
ユーザー chineristACchineristAC
提出日時 2021-05-28 19:32:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 1,968 bytes
コンパイル時間 9,634 ms
コンパイル使用メモリ 300,036 KB
実行使用メモリ 20,204 KB
最終ジャッジ日時 2024-04-24 22:19:07
合計ジャッジ時間 11,454 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 185 ms
12,016 KB
testcase_02 AC 230 ms
20,204 KB
testcase_03 AC 229 ms
20,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <random>
#include <stdio.h>
#include <fstream>
#include <functional>
#include <atcoder/all>
#include "testlib.h"
#include <cassert>
using namespace std;
using namespace atcoder;

#define rep(i,n,c) for (int i=0;i<n;i+=c)
#define append push_back
#define all(x) (x).begin(), (x).end()

template<class T>
using vec = vector<T>;
template<class T>
using vvec = vec<vec<T>>;
template<class T>
using vvvec = vec<vvec<T>>;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;


template<class T>
bool chmin(T &a, T b){
  if (a>b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
bool chmax(T &a, T b){
  if (a<b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
T sum(vec<T> x){
  T res=0;
  for (auto e:x){
    res += e;
  }
  return res;
}

template<class T>
void printv(vec<T> x){
  for (auto e:x){
    cout<<e<<" ";
  }
  cout<<"\n";
}


const ll INF = 1e17;

const ll MIN_L = 0;
const ll MAX_L = 1ll<<50;
const ll MIN_R = 0;
const ll MAX_R = 1ll<<50;

int main(int argc, char* argv[]){
  registerValidation(argc,argv);
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int t;
  t = inf.readInt(1,100000,"t");
  inf.readEoln();
  ll L,R;
  while (t--){
    L = inf.readLong(MIN_L,MAX_L);
    inf.readSpace();
    R = inf.readLong(L,MAX_R);
    inf.readEoln();

    if ((L+R)%2==1){
      ll cnt = (R-L+1)/2;
      if (cnt%4==1 or cnt%4==2){
        cout<<1<<endl;
      }
      else{
        cout<<0<<endl;
      }
    }
    else{
      ll cnt = (R-L)/2;
      if (cnt%4==1 or cnt%4==2){
        cnt = 1;
      }
      else{
        cnt = 0;
      }
      ll val = (L+R)/2-L+1;
      if (val%2==1){
        cnt ^= L+R;
        cout<<cnt<<endl;
      }
      else{
        cout<<cnt<<endl;
      }
    }
  }
  inf.readEof();

  

}
0