結果

問題 No.1930 XOR of Two Range
ユーザー chineristACchineristAC
提出日時 2021-03-09 01:37:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 1,083 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 82,488 KB
最終ジャッジ日時 2023-08-07 06:21:46
合計ジャッジ時間 2,890 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
74,468 KB
testcase_01 AC 226 ms
82,488 KB
testcase_02 AC 206 ms
81,896 KB
testcase_03 AC 206 ms
81,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

def solve(L,R):
    if (L+R)%2:
        n = (L+R-1)//2-L+1
        res = n*(n+1)//2
        return res%2
    else:
        n = (L+R-2)//2-L+1
        res = n*(n+1)//2
        res %= 2
        if ((L+R)//2-L+1)%2:
            return (L+R)^res
        else:
            return res

for _ in range(int(input())):
    L,R = mi()
    print(solve(L,R))
0