結果

問題 No.1895 Mod 2
ユーザー MasKoaTSMasKoaTS
提出日時 2022-04-19 21:53:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 1,083 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 86,496 KB
最終ジャッジ日時 2023-08-30 19:50:37
合計ジャッジ時間 5,182 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 214 ms
81,644 KB
testcase_01 AC 266 ms
84,848 KB
testcase_02 AC 298 ms
86,496 KB
testcase_03 AC 255 ms
84,920 KB
testcase_04 AC 264 ms
85,476 KB
testcase_05 AC 258 ms
84,900 KB
testcase_06 AC 258 ms
85,000 KB
testcase_07 AC 254 ms
85,148 KB
testcase_08 AC 266 ms
85,088 KB
testcase_09 AC 271 ms
85,216 KB
testcase_10 AC 257 ms
84,980 KB
testcase_11 AC 266 ms
85,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools as iter
import collections as coll
import heapq as hq
import bisect as bis
from decimal import Decimal as dec
from functools import cmp_to_key
import math
import sys
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
sys.setrecursionlimit(10 ** 6)
inp = sys.stdin.readline
input = lambda : inp().rstrip()
getN = lambda : int(inp())
getNs = lambda : map(int, inp().split())
getList = lambda :list(map(int, inp().split()))
getStrs = lambda n : [input() for _ in [0] * n]
def yexit(): print("Yes"); exit(0)
def nexit(): print("No"); exit(0)
pi = 3.141592653589793
mod = 1000000007
MOD = 998244353
INF = 4611686018427387903
dx = [1, 0, -1, 0];	dy = [0, 1, 0, -1]

def isqrt(n):
	rn = math.sqrt(n)
	ok = int(rn - 2)
	ng = int(rn + 2)
	while(ng - ok > 1):
		k = (ok + ng) >> 1
		if(k * k <= n):
			ok = k
		else:
			ng = k
	return ok


"""
Main Code
"""

for _ in [0] * getN():
	a, b = getNs()
	ans = 0
	l = isqrt(a);	l += (l * l < a)
	r = isqrt(b)
	ans += r - l + 1
	l = isqrt(a // 2);	l += (l * l * 2 < a)
	r = isqrt(b // 2)
	ans += r - l + 1
	print(ans & 1)
0