Untitled

 avatar
unknown
plain_text
a year ago
506 B
6
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';
    }
}