結果
問題 | No.1895 Mod 2 |
ユーザー | chineristAC |
提出日時 | 2022-04-08 21:55:09 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 601 ms / 2,000 ms |
コード長 | 2,453 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 79,616 KB |
最終ジャッジ日時 | 2024-11-28 12:35:46 |
合計ジャッジ時間 | 5,136 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 57 ms
62,464 KB |
testcase_01 | AC | 289 ms
78,336 KB |
testcase_02 | AC | 350 ms
79,616 KB |
testcase_03 | AC | 254 ms
78,208 KB |
testcase_04 | AC | 348 ms
78,976 KB |
testcase_05 | AC | 403 ms
78,848 KB |
testcase_06 | AC | 408 ms
78,780 KB |
testcase_07 | AC | 601 ms
79,360 KB |
testcase_08 | AC | 270 ms
78,208 KB |
testcase_09 | AC | 271 ms
78,468 KB |
testcase_10 | AC | 252 ms
78,588 KB |
testcase_11 | AC | 458 ms
79,104 KB |
ソースコード
from collections import deque class Dinic: def __init__(self, N): self.N = N self.G = [[] for i in range(N)] def add_edge(self, fr, to, cap): forward = [to, cap, None] forward[2] = backward = [fr, 0, forward] self.G[fr].append(forward) self.G[to].append(backward) def add_multi_edge(self, v1, v2, cap1, cap2): edge1 = [v2, cap1, None] edge1[2] = edge2 = [v1, cap2, edge1] self.G[v1].append(edge1) self.G[v2].append(edge2) def bfs(self, s, t): self.level = level = [None]*self.N deq = deque([s]) level[s] = 0 G = self.G while deq: v = deq.popleft() lv = level[v] + 1 for w, cap, _ in G[v]: if cap and level[w] is None: level[w] = lv deq.append(w) return level[t] is not None def dfs(self, v, t, f): if v == t: return f level = self.level for e in self.it[v]: w, cap, rev = e if cap and level[v] < level[w]: d = self.dfs(w, t, min(f, cap)) if d: e[1] -= d rev[1] += d return d return 0 def flow(self, s, t): flow = 0 INF = 10**9 + 7 G = self.G while self.bfs(s, t): *self.it, = map(iter, self.G) f = INF while f: f = self.dfs(s, t, INF) flow += f return flow import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) def calc_h(k,R): """ (2n-1)^2 * 2^k <= R """ if 2**k > R: return 0 R >>= k ok = 1 ng = 10**9 while ng-ok>1: mid = (ok+ng)//2 if (2*mid-1)**2 <= R: ok = mid else: ng = mid return ok def calc(R): if R==0: return 0 res = 0 for k in range(0,50,2): """ [R/2] < (2n-1)^2 * 2^k <= R """ tmp = calc_h(k,R) - calc_h(k,R//2) res += tmp return res&1 for _ in range(int(input())): L,R = mi() res = calc(R) - calc(L-1) print(res&1)