結果

問題 No.1930 XOR of Two Range
ユーザー tnakao0123tnakao0123
提出日時 2022-05-08 22:11:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 41,092 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 20:42:35
合計ジャッジ時間 1,676 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1930.cc:  No.1930 XOR of Two Range - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    ll l, r;
    scanf("%lld%lld", &l, &r);
    ll k = r + 1 - l;
    ll x = k / 4, y = k % 4;

    ll sum = x & 1;
    if (y == 1) sum ^= 2 * l + x * 4;
    else if (y > 1) sum ^= 1;

    printf("%lld\n", sum);
  }
  return 0;
}
0