zoukankan      html  css  js  c++  java
  • B. Multiplication Table (模拟) ( Codeforces Round #586 (Div. 1 + Div. 2) )

    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=aiajMij=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 (3n1033⩽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 (1Mij1091≤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 (1ai1091≤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 

     

     

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <string>
    #include <cstring>
    #include <cstdlib>
    #include <map>
    #include <vector>
    #include <set>
    #include <queue>
    #include <stack>
    #include <cmath>
    using namespace std;
    #define pq priority_queue<int>
    #define pql priority_queue<ll>
    #define pqn priority_queue<node>
    #define v vector<int>
    #define vl vector<ll>
    #define lson rt<<1, l, m
    #define rson rt<<1|1, m+1, r
    #define read(x) scanf("%d",&x)
    #define lread(x) scanf("%lld",&x);
    #define pt(x) printf("%d
    ",(x))
    #define yes printf("YES
    ");
    #define no printf("NO
    ");
    #define gcd __gcd
    #define out(x) cout<<x<<endl;
    #define over cout<<endl;
    #define rep(j,k) for (int i = (int)(j); i <= (int)(k); i++)
    #define input(k) for (int i = 1; i <= (int)(k); i++)  {cin>>a[i] ; }
    #define mem(s,t) memset(s,t,sizeof(s))
    #define re return ;
    #define ok return 0;
    #define TLE std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define mod(x) ((x)%9973)
    #define test  cout<<"       ok             "<<endl;
    #define ls now<<1
    #define lli long long
    const int mxn = 1e3+5;
    lli a[mxn][mxn];
    lli dp[mxn];
    int gcd(int m, int n)
    {
        while(m>0)
        {
            int c = n % m;
            n = m;
            m = c;
        }
        return n;
    }
    int main()
    {
        TLE;
        int n,ans,cnt;
        string str;
        while(cin>>n)
        {
            for(int i=1; i<=n; i++)
                for(int j=1; j<=n; j++)
                {
                    cin>>a[i][j];
                }
            dp[1] = sqrt(a[1][2]*a[1][3]/a[2][3] );
            for(int i=2;i<=n;i++)
                dp[i] = a[1][i]/dp[1];
            cout<<dp[1];
            for(int i=2;i<=n;i++)
                cout<<" "<<dp[i];
            cout<<endl;
        }
        ok;
    }
    所遇皆星河
  • 相关阅读:
    golang json字符串合并操作
    goland 无法跳转 struct等
    golang 中mgo update报错: The dollar ($) prefixed field '$inc' in '$inc' is not valid for storage.
    解决windows下使用vscode没有函数提示的问题
    【转载,实测好用】gitlab结合sourcetree使用
    C++单继承、多继承情况下的虚函数表分析
    Linux 日志文件管理——限制大小
    C++ RCSP智能指针简单实现与应用
    Makefile模板(C++)
    Git关于pull,commit,push的总结
  • 原文地址:https://www.cnblogs.com/Shallow-dream/p/11586974.html
Copyright © 2011-2022 走看看