链接:

https://codeforces.com/contest/1220/problem/B

题意:

Sasha grew up and went to first grade. To celebrate this event her mother bought her a multiplication table M with n rows and n columns such that Mij=ai⋅aj where a1,…,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,…,an. Help Sasha restore the array!

思路:

a1 = sqrt(a1a2a1a3/(a2a3))

然后挨个计算.

代码:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL; const int MAXN = 1e3+10;
LL MT[MAXN][MAXN];
LL a[MAXN];
int n; int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1;i <= n;i++)
{
for (int j = 1;j <= n;j++)
cin >> MT[i][j];
}
a[1] = sqrt((MT[1][2]*MT[1][3])/MT[2][3]);
for (int i = 2;i <= n;i++)
a[i] = MT[i-1][i]/a[i-1];
for (int i = 1;i <= n;i++)
cout << a[i] << ' ' ;
cout << endl; return 0;
}

最新文章

  1. C#调用win32 api 操作其它窗口
  2. sql server 2008中清除数据库日志的sql语句
  3. jQuery原型属性和方法总结
  4. Linux下安装APache
  5. windows系统服务编程代码示例分享
  6. 黑马程序员:Java编程_集合
  7. Web开发中错误页面的配置
  8. STL中vector的用法
  9. ios开发--GCD使用介绍:4-延迟执行操作
  10. python ssh弱口令爆破多线程脚本及遇到的一些错误与问题
  11. 一台nginx服务器多域名配置 (转)
  12. 以太网PHY 芯片之 MII/MDIO接口详解
  13. Bash中的数学计算
  14. Lastpass&mdash;&mdash;密码管理工具
  15. 【python标准库模块一】时间模块time学习
  16. ssm框架各自的作用
  17. tqdm介绍及常用方法
  18. 读《流畅的python》第一天
  19. 如何让div弄成可以输入文字
  20. vc++基础班[26]---进程的相关操作

热门文章

  1. Connect4 Game
  2. The Maze II
  3. [转帖]ubuntu 修改 apt源的方法
  4. Spring实例化Bean三种方法:构造器、静态工厂、实例工厂
  5. Reactor 线程模型以及在netty中的应用
  6. typora的基本使用技巧汇总
  7. 认识函数(python)
  8. 【数学】Eddy Walker
  9. java lesson09总结
  10. 守护服务Supervisor的安装和使用