結果

問題 No.1895 Mod 2
ユーザー 👑 KazunKazun
提出日時 2022-04-08 22:01:10
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 909 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 83,584 KB
最終ジャッジ日時 2024-05-06 07:34:24
合計ジャッジ時間 13,380 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
66,304 KB
testcase_01 TLE -
testcase_02 TLE -
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def General_Binary_Decrease_Search_Integer(L,R,cond,default=None):
    """条件式が単調減少であるとき, 整数上で二部探索を行う.
    L:解の下限
    R:解の上限
    cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす)
    default: Rで条件を満たさないときの返り値
    """

    if not(cond(L)): return default

    if cond(R): return R

    L-=1
    while R-L>1:
        C=L+(R-L)//2
        if cond(C): L=C
        else: R=C
    return L
#==================================================
def g(x):
    y=1
    a=0
    while y<=x:
        check=lambda i:y*(2*i-1)**2<=x
        a+=General_Binary_Decrease_Search_Integer(1,x//y,check,0)
        y*=2
    return a
#==================================================
T=int(input())
Ans=[0]*T
for t in range(T):
    L,R=map(int,input().split())
    Ans[t]=(g(R)-g(L-1))%2

print(*Ans,sep="\n")
0