중간에 2의 배수가 몇개 채워져야 하나?
앞 뒤 비교해서 나누면서 세주거나 작은거에서 곱하면서 세주면 된다.
import sys
input = sys.stdin.readline
for test in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
answer = 0
for i in range(n - 1):
a, b = arr[i], arr[i + 1]
if a > b:
a, b = b, a
while 2 * a < b:
answer += 1
b /= 2
print(answer)
'practivceAlgorithm > codeforce' 카테고리의 다른 글
[Codeforce][Python] #702 C. Sum of Cubes (0) | 2021.11.07 |
---|---|
[Codeforce][Python] #702 B. Balanced Remainders (0) | 2021.11.07 |
[codeforce][Python] #719 E.Arranging The Sheep (0) | 2021.10.17 |
[codeforce][Python] #719 D.Same Differences (0) | 2021.10.17 |
[codeforce][Python] #719 C.Not Adjacent Matrix (0) | 2021.10.17 |