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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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(ai,a(i+1)modn), where gcd(x,y) is the best normal divisor of x and y, and xmody is the rest of x separating by y. In one stage the cluster b is constructed and afterward the exhibit an is supplanted with b (that is, the task a := b is occurring). 

 

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.

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education