Multiplication Table

B. Multiplication Table

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Sasha grew up and went to first grade. To celebrate this event her mother bought her a multiplication table MM with nn rows and nn columns such that Mij=ai⋅ajMij=ai⋅aj where a1,…,ana1,…,an is some sequence of positive integers.

Of course, the girl decided to take it to school with her. But while she was having lunch, hooligan Grisha erased numbers on the main diagonal and threw away the array a1,…,ana1,…,an. Help Sasha restore the array!

Input

The first line contains a single integer nn (3⩽n⩽1033⩽n⩽103), the size of the table.

The next nn lines contain nn integers each. The jj-th number of the ii-th line contains the number MijMij (1≤Mij≤1091≤Mij≤109). The table has zeroes on the main diagonal, that is, Mii=0Mii=0.

Output

In a single line print nn integers, the original array a1,…,ana1,…,an (1≤ai≤1091≤ai≤109). It is guaranteed that an answer exists. If there are multiple answers, print any.

Examples

input

Copy

5
0 4 6 2 4
4 0 6 2 4
6 6 0 3 6
2 2 3 0 2
4 4 6 2 0

output

Copy

2 2 3 1 2 

input

Copy

3
0 99990000 99970002
99990000 0 99980000
99970002 99980000 0

output

Copy

9999 10000 9998 

 

給你一個n*n的矩陣,m[i][j]=a[i]*a[j],讓你求出a這個數列。

 

把矩陣用字符表達寫出來,m[i][j]=a[i]*a[j];

就很好發現a[1]=sqrt(m[1][2]*m[1][3]/m[2][3]);

 那麼根據m[1][2],m[2][3],...,m[i][i+1],m[n-1][n]就可以求出a[2],a[3],..,a[I+1],a[n].

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#define INF 0x3f3f3f3f
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a)) 
using namespace std;
LL map[1010][1010],a[1010];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>map[i][j];
	a[1]=sqrt(map[1][2]*map[1][3]/map[2][3]);
	cout<<a[1]<<' ';
	for(int i=1;i<n;i++)
	{
		a[i+1]=map[i][i+1]/a[i];
		cout<<a[i+1]<<' ';
	}
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章