-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11.bisearch.py
More file actions
28 lines (28 loc) · 764 Bytes
/
11.bisearch.py
File metadata and controls
28 lines (28 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import sys
sys.stdin = open("sample_input.txt", "r")
T = int(input())
for test_case in range(1, T + 1):
info = list(map(int, input().split()))
result = []
for j in range(2):
left = 1
right = info[0]
page = info[j+1]
cnt = 0
while left <= right:
mid = (left+right)//2
if mid == page:
break
elif mid < page:
left = mid
cnt += 1
else:
right = mid
cnt += 1
result.append(cnt)
if result[0] < result[1]:
print('#'+str(test_case),'A')
if result[0] > result[1]:
print('#'+str(test_case),'B')
if result[0] == result[1]:
print('#'+str(test_case),'0')