結果

問題 No.1895 Mod 2
ユーザー ああいいああいい
提出日時 2022-04-08 22:20:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,562 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 87,028 KB
実行使用メモリ 80,760 KB
最終ジャッジ日時 2023-08-19 00:50:02
合計ジャッジ時間 11,621 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
75,636 KB
testcase_01 AC 846 ms
77,848 KB
testcase_02 AC 1,054 ms
80,760 KB
testcase_03 AC 877 ms
77,916 KB
testcase_04 AC 1,075 ms
77,840 KB
testcase_05 AC 1,474 ms
78,960 KB
testcase_06 AC 1,471 ms
79,772 KB
testcase_07 AC 1,562 ms
78,848 KB
testcase_08 AC 506 ms
78,460 KB
testcase_09 AC 523 ms
79,328 KB
testcase_10 AC 157 ms
77,580 KB
testcase_11 AC 836 ms
78,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

def calc(x):
    ans = 0
    i = 1
    while i <= x:
        end = x + 1
        start = 1
        while end - start > 1:
            mid = end + start >> 1
            if mid * mid * i <= x:
                start = mid
            else:
                end = mid
        #print(i,x,(start + 1) % 2)
        ans += (start + 1) // 2 % 2
        i *= 2
    return ans % 2
for _ in range(T):
    l,r = map(int,input().split())
    ans = calc(r) - calc(l-1)
    print(ans%2)
0