五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CF 1490A - Dense Array

2023-06-16 14:16 作者:您是打尖兒還是住店呢  | 我要投稿

Polycarp calls an array dense if the greater of any two adjacent elements is not more than twice bigger than the smaller. More formally, for any i

?(1≤i≤n?1), this condition must be satisfied:max(a[i],a[i+1])/min(a[i],a[i+1])≤2

For example, the arrays [1,2,3,4,3], [1,1,1] and [5,10] are dense. And the arrays [5,11]

, [1,4,2], [6,6,1] are not dense.

You are given an array a of n integers. What is the minimum number of numbers you need to add to an array to make it dense? You can insert numbers anywhere in the array. If the array is already dense, no numbers need to be added.

For example, if a=[4,2,10,1], then the answer is 5, and the array itself after inserting elements into it may look like this: a=[4,2,3––,5––,10,6––,4––,2––,1] (there are other ways to build such a).

Input

The first line contains one integer t (1≤t≤1000). Then t test cases follow.

The first line of each test case contains one integer n (2≤n≤50) — the length of the array a

.The next line contains n integers a1,a2,…,an (1≤ai≤50).

Output

For each test case, output one integer — the minimum number of numbers that must be added to the array to make it dense.

Example

input

6

4

4 2 10 1

2

1 3

2

6 1

3

1 4 2

5

1 2 3 4 3

12

4 31 25 50 30 20 34 46 42 16 15 16

output

5

1

2

1

0

3

Note

The first test case is explained in the statements.

In the second test case, you can insert one element, a=[1,2––,3].

In the third test case, you can insert two elements, a=[6,4––,2––,1].

In the fourth test case, you can insert one element, a=[1,2––,4,2].

In the fifth test case, the array a is already dense.

判斷數(shù)組是否是稠密的,就是判斷2個(gè)元素是否需要插入數(shù)據(jù),就用二分法,將小的依次乘以2,然后再去判斷,依次即可。

最后返回?cái)?shù)據(jù);

下面是代碼:


CF 1490A - Dense Array的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
安阳县| 五常市| 开江县| 锡林郭勒盟| 洮南市| 玉田县| 肇源县| 奇台县| 弋阳县| 宜黄县| 项城市| 湛江市| 华安县| 五指山市| 防城港市| 株洲县| 秦皇岛市| 金寨县| 灵山县| 盱眙县| 台南县| 措美县| 黑水县| 若羌县| 呼伦贝尔市| 沂南县| 察哈| 会东县| 西充县| 封开县| 长岭县| 东港市| 花莲县| 英吉沙县| 兰考县| 遂川县| 庆阳市| 台南县| 泸西县| 吴江市| 海盐县|