Not able to get answer

Here i am trying this question…
https://codeforces.com/problemset/problem/1220/B
This is my solution…
I have arrived on some logic… But it is showing wrong answer for test case-2.


Please see this.

hello @ashishnnnnn

what logic u r implementing .
is it a[i]=gcd of ith row?

check this->
mat[i][j]=a[i]*a[j] // as per definition
mat[i][j+1]=a[i]*a[j+1]

mat[i][j]*mat[i][j+1]= a[i]^2 * a[j] * a[j+1]
also a[j] * a[j+1] is nothing but mat[j][j+1] right? // as per definition
so we can write
mat[i][j]*mat[i][j+1]=a[i]^2 * mat[j][j+1]

a[i]^2= mat[i][j] * mat[i][j+1] / mat[j][j+1]
now simply compute square root to this term to get a[i]

Yes…
https://codeforces.com/problemset/submission/1220/97621449
I am calculating gcd of each row.

see gcd of ith row can be greater than a[i]
so if we use gcd as [i] then it will put constraints on other elements.(which is tough to handle)

for example->
[ 2 * 4 , 2*8 ]
here gcd can be greater than 2 ( 8 in case )
so if we put 8 as a[i] then it impose constraint of other a[i]'s