結果

問題 No.1895 Mod 2
ユーザー siganaisiganai
提出日時 2022-04-09 16:56:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 759 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 81,356 KB
最終ジャッジ日時 2023-08-19 20:52:59
合計ジャッジ時間 3,496 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
78,988 KB
testcase_01 AC 202 ms
81,224 KB
testcase_02 AC 186 ms
81,348 KB
testcase_03 AC 166 ms
81,092 KB
testcase_04 AC 167 ms
80,940 KB
testcase_05 AC 167 ms
81,216 KB
testcase_06 AC 166 ms
81,008 KB
testcase_07 AC 169 ms
81,304 KB
testcase_08 AC 176 ms
81,180 KB
testcase_09 AC 182 ms
81,264 KB
testcase_10 AC 157 ms
80,656 KB
testcase_11 AC 181 ms
81,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
import heapq
import functools
mod=10**9+7

import sys
input=sys.stdin.readline

t = int(input())

def count(x):
    res = 0
    if x >= 10 ** 7:
        sq = int(math.sqrt(x) - 2)
        while (sq + 1) ** 2 <= x:
            sq += 1
    else:
        sq = int(math.sqrt(x))
    res += sq
    if x >= 10 ** 7:
        dsq = int(math.sqrt(x//2) - 2)
        while (dsq + 1) ** 2 * 2 <= x:
            dsq += 1
    else:
        dsq = int(math.sqrt(x//2))
    res += dsq
    return res

for _ in range(t):
    l,r=map(int,input().split())
    ans = count(r) - count(l-1)
    print(ans%2)

0