結果

問題 No.1895 Mod 2
ユーザー rlangevinrlangevin
提出日時 2023-04-25 08:57:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-04-26 16:25:57
合計ジャッジ時間 2,407 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,352 KB
testcase_01 AC 92 ms
76,416 KB
testcase_02 AC 107 ms
76,544 KB
testcase_03 AC 96 ms
76,544 KB
testcase_04 AC 88 ms
76,160 KB
testcase_05 AC 102 ms
76,672 KB
testcase_06 AC 104 ms
76,032 KB
testcase_07 AC 100 ms
76,672 KB
testcase_08 AC 95 ms
76,032 KB
testcase_09 AC 96 ms
76,032 KB
testcase_10 AC 89 ms
76,160 KB
testcase_11 AC 95 ms
76,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

def f(x):
    yes = 0
    no = 10 ** 9
    while no - yes != 1:
        mid = (yes + no)//2
        if mid * mid <= x:
            yes = mid
        else:
            no = mid
    ans = yes

    yes = 0
    no = 10 ** 9
    while no - yes != 1:
        mid = (yes + no)//2
        if 2 * mid * mid <= x:
            yes = mid
        else:
            no = mid
    return (ans + yes) % 2
    

T = int(readline())
for _ in range(T):
    L, R = map(int, readline().split())
    print((f(R) - f(L - 1)) % 2)
0