結果

問題 No.1895 Mod 2
ユーザー 👑 rin204rin204
提出日時 2022-04-08 21:39:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 79,116 KB
最終ジャッジ日時 2023-08-19 00:18:54
合計ジャッジ時間 2,412 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,676 KB
testcase_01 AC 124 ms
78,124 KB
testcase_02 AC 129 ms
79,116 KB
testcase_03 AC 134 ms
78,908 KB
testcase_04 AC 131 ms
78,320 KB
testcase_05 AC 140 ms
78,040 KB
testcase_06 AC 124 ms
78,256 KB
testcase_07 AC 125 ms
78,000 KB
testcase_08 AC 122 ms
78,216 KB
testcase_09 AC 124 ms
78,176 KB
testcase_10 AC 120 ms
77,880 KB
testcase_11 AC 132 ms
77,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""
x = 奇数の平方数 * 2^n
で表されるとき
f(x) = 1

x = 平方数 or 平方数 * 2
"""
def f(x):
    if x == 0:
        return 0
    i = int(x ** 0.5)
    i -= 2
    while (i + 1) ** 2 <= x:
        i += 1
    ret = i
    
    i = int((x // 2) ** 0.5)
    i -= 2
    while 2 * (i + 1) ** 2 <= x:
        i += 1
    return ret + i

def solve():
    l, r = map(int, input().split())
    ans = f(r) - f(l - 1)
    print(ans % 2)

for _ in range(int(input())):
    solve()
0