Here gcd(x,y) means the best normal divisor (GCD) of integers x and y, and lcm(x,y) indicates the most un-normal numerous (LCM) of integers x and y. You are given an exhibit an of length n. Each second the accompanying occurs: every component computer based intelligence of the exhibit is supplanted by the
Correct answer will be upvoted else Multiple Downvoted. Computer science.
Here gcd(x,y) means the best normal divisor (GCD) of integers x and y, and lcm(x,y) indicates the most un-normal numerous (LCM) of integers x and y.
You are given an exhibit an of length n. Each second the accompanying occurs: every component computer based intelligence of the exhibit is supplanted by the result of all components of the cluster (counting itself), that are neighboring the current worth.
Let di be the number of neighboring components to
You are given q questions: each inquiry is portrayed by an integer w, and you need to output the excellence of the exhibit after w seconds.
Input
The originally input line contains a solitary integer t (1≤t≤105) — the number of experiments.
The main line of each experiment contains a solitary integer n (1≤n≤3⋅105) — the length of the cluster.
The accompanying line contains n integers a1,… ,an (1≤ai≤106) — cluster components.
The following line contain a solitary integer q (1≤q≤3⋅105) — the number of inquiries.
The accompanying q lines contain a solitary integer w each (0≤w≤1018) — the actual questions.
It is ensured that the amount of qualities n over all experiments doesn't surpass 3⋅105, and the amount of qualities q over all experiments doesn't surpass 3⋅105
Output
For each inquiry output a solitary integer — the magnificence of the exhibit at the comparing second.
Step by step
Solved in 4 steps with 1 images