practivceAlgorithm/codeforce
[Codeforce][Python] #702 A.Dense Array
findTheValue
2021. 11. 7. 02:13
중간에 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)