結果

問題 No.1895 Mod 2
ユーザー 👑 KazunKazun
提出日時 2022-04-09 13:53:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 730 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 76,544 KB
最終ジャッジ日時 2024-05-07 00:47:26
合計ジャッジ時間 1,978 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,352 KB
testcase_01 AC 81 ms
73,600 KB
testcase_02 AC 102 ms
76,544 KB
testcase_03 AC 77 ms
72,704 KB
testcase_04 AC 93 ms
76,244 KB
testcase_05 AC 80 ms
74,240 KB
testcase_06 AC 82 ms
74,756 KB
testcase_07 AC 81 ms
74,752 KB
testcase_08 AC 90 ms
76,544 KB
testcase_09 AC 93 ms
76,260 KB
testcase_10 AC 77 ms
73,472 KB
testcase_11 AC 85 ms
76,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#floor(a^(1/k)) を求める.
def Floor_Root(a,k):
    """floor(a^(1/k)) を求める.

    a:非負整数
    k:正の整数
    """
    assert 0<=a and 0<k
    if a==0: return 0
    if k==1: return a

    #大体の値を求める.
    x=int(pow(a,1/k))

    #増やす
    while pow(x+1,k)<=a:
        x+=1

    #減らす
    while pow(x,k)>a:
        x-=1
    return x
#==================================================
def g(x):
    return Floor_Root(x,2)+Floor_Root(x//2,2)
#==================================================
import sys
input=sys.stdin.readline
write=sys.stdout.write

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

write("\n".join(map(str,Ans)))
0