Untitled
unknown
plain_text
2 years ago
506 B
12
Indexable
#include <iostream>
#include <cmath>
using namespace std;
int main () {
int t;
cin >> t;
while (t--) {
long ans=0, n, num, prev;
cin >> n;
n--; cin >> prev;
while (n--) {
cin >> num;
if (num >= prev) {
prev = num;
continue;
}
long res = ceil(log2((prev*1.0 / num)));
ans += res;
prev = num * (1LL << res);
}
cout << int(ans) << '\n';
}
}Editor is loading...