exhibit an is supplanted with one more cluster of length n, in which every component is the best normal divisor (GCD) of two adjoining components (the actual component and its right neighbor; consider that the right neighbor of the (n−1)- th component is the 0-th component). Officially talking, another exhibit b=[b0,b1,… ,bn−1] is being worked
Correct answer will upvoted else downvoted.
exhibit an is supplanted with one more cluster of length n, in which every component is the best normal divisor (GCD) of two adjoining components (the actual component and its right neighbor; consider that the right neighbor of the (n−1)- th component is the 0-th component).
Officially talking, another exhibit b=[b0,b1,… ,bn−1] is being worked from cluster a=[a0,a1,… ,an−1] to such an extent that bi =gcd(
For instance, on the off chance that a=[16,24,10,5], b=[gcd(16,24), gcd(24,10), gcd(10,5), gcd(5,16)] =[8,2,5,1]. Along these lines, after one stage the exhibit a=[16,24,10,5] will be equivalent to [8,2,5,1].
For a given exhibit a, track down the base number of steps after which all qualities simulated intelligence become equivalent (that is, a0=a1=⋯=an−1). In the event that the first exhibit a comprises of indistinguishable components, consider the number of steps is equivalent to 0.
Input :The principal line contains an integer t (1≤t≤104). Then, at that point, t experiments follow. Each experiment contains two lines. The main line contains an integer n (2≤n≤2⋅105) — length of the grouping a. The subsequent line contains n integers a0,a1,… ,an−1 (1≤ai≤106). It is ensured that the amount of n over all experiments doesn't surpass 2⋅105.
Output :Print t numbers — deals with serious consequences regarding each experiment.
Step by step
Solved in 4 steps with 2 images