COFO::1220B Multiplication Table

Problem

Point

Design

Complexity

Code

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define r_rep(i, a, b) for(int i=(a); i >(b); i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll n;
ll m[1009][1009];
ll ans[1009];
void solve(){
    cin >> n;
    rep(i, 0, n) rep(j, 0, n) cin >> m[i][j];
    ll a0a1 = m[0][1], a0a2 = m[0][2], a1a2 = m[1][2];
    ans[0] = sqrt(a0a1 * a0a2 / a1a2);
    ans[1] = a0a1 / ans[0];
    ans[2] = a0a2 / ans[0];
    rep(i, 3, n) ans[i] = m[i-1][i] / ans[i-1];
    rep(i, 0, n) cout << ans[i] << " ";
    cout <<'\n';
}
int main(){
    solve();
    return 0;
}