結果

問題 No.1930 XOR of Two Range
ユーザー chineristACchineristAC
提出日時 2021-03-09 01:37:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 627 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 78,336 KB
最終ジャッジ日時 2024-04-25 00:29:50
合計ジャッジ時間 2,055 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
55,552 KB
testcase_01 AC 178 ms
78,336 KB
testcase_02 AC 163 ms
78,080 KB
testcase_03 AC 163 ms
77,696 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