Google-Developer-Student-Club-CCOEW / Competitive-Coding

7 stars 51 forks source link

Question 73 #157

Closed Mahi1901 closed 2 years ago

Mahi1901 commented 2 years ago

Sasuke and Itachi are playing a game. Sasuke first creates an array AA containing NN positive integers A1, A2,…,AN. He then creates a new array BB of length NN such that Bi=gcd (A1 ,A2,...,Ai) for each 1≤i≤N. Now, Sasuke gives array BB to Itachi and asks him to find any array AA (with 1≤Ai≤10^9) such that the given process applied to AA will produce BB. Can you help Itachi solve this problem? Here, gcd stands for greatest common divisor.

Input Format The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows. The first line of each test case contains a single integer NN. The second line contains NN space-separated integers B1, B2,…,BN ​

Output Format For each test case, print a single line containing NN space-separated integers denoting the array AA you constructed. If no such array AA exists, print -1 instead.

Constraints 1≤T≤10^3 1≤N≤10^5 1≤Ai, Bi≤10^9

It is guaranteed that sum of NN over all test cases doesn't exceed 5×10^5.

Sample 1: Input 2 2 4 2 2 1 3 Output 4 26 -1

kasturimandlik commented 2 years ago

Kasturi Mandlik Cummins college of engineering for women Dept: Electronics and telecommunication I would like to work on this issue. Can you please assign me this issue?

JanhaviGadre commented 2 years ago

Janhavi Gadre Cummins college of engineering for women Dept: Computer I would like to work on this issue. Can you please assign me this issue?

NikitaMiraje commented 2 years ago

Nikita Miraje Cummins college of engineering for women Dept: Electronics and telecommunication I would like to work on this issue. Can you please assign me this issue?

kasturimandlik commented 2 years ago

@Mahi1901 Can you please assign me this issue?

ManasiGDeshmukh commented 2 years ago

Manasi Deshmukh Cummins college of engineering for women Dept: Computer Engineering I would like to work on this issue. Can you please assign me this issue?

ShrutikaK2911 commented 2 years ago

Shrutika Kaperavenollu CCOEW IT I would like to work on this issue. Can you please assign me this issue?

Mahi1901 commented 2 years ago

I have assigned. Happy coding!

kasturimandlik commented 2 years ago

@Mahi1901 I have completed my assignment. Please do check and merge my pull request.

aditi3004 commented 2 years ago

HEY!!! This is Aditi Sharma(SY-C) MKSSS's CCOEW Computer Engineering

I want to work on this issue Can you assign this to me?