結果

問題 No.1895 Mod 2
ユーザー siganaisiganai
提出日時 2022-04-09 16:56:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 759 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,040 KB
実行使用メモリ 78,644 KB
最終ジャッジ日時 2024-05-07 03:55:28
合計ジャッジ時間 2,513 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
65,172 KB
testcase_01 AC 105 ms
78,004 KB
testcase_02 AC 115 ms
78,192 KB
testcase_03 AC 94 ms
78,216 KB
testcase_04 AC 100 ms
77,772 KB
testcase_05 AC 100 ms
77,952 KB
testcase_06 AC 98 ms
77,932 KB
testcase_07 AC 97 ms
77,952 KB
testcase_08 AC 103 ms
78,260 KB
testcase_09 AC 110 ms
77,984 KB
testcase_10 AC 86 ms
77,752 KB
testcase_11 AC 114 ms
78,644 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