链接:

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;
}

Codeforces Round #586 (Div. 1 + Div. 2) B. Multiplication Table的更多相关文章

  1. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  2. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  3. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  4. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  5. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  6. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  7. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  8. Educational Codeforces Round 39 (Rated for Div. 2) G

    Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...

  9. Educational Codeforces Round 48 (Rated for Div. 2) CD题解

    Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...

  10. Educational Codeforces Round 60 (Rated for Div. 2) 题解

    Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...

随机推荐

  1. pytorch安装问题

    目录 1.版本 2.pytorch调试中出现的Module 'torch' has no 'zero' member如何解决 3.No module named 'numpy.core._multia ...

  2. [转帖]sys.dm_exec_connections (Transact-SQL)

    sys.dm_exec_connections (Transact-SQL) https://docs.microsoft.com/en-us/sql/relational-databases/sys ...

  3. 记录一次hadoop2.8.4版本RM接入zk ha问题

    背景: 公司将线上hadoop RM接入ZK 实现高可用 但ZK Znode 默认存储1M,当存储数据量大时候可能导致线上业务的崩溃 处理方案如下: 1,修改ZK配置 增加默认存储上限 2,修改RM数 ...

  4. Python中几个必须知道的函数

    Python中自带了几个比较有意思的函数,一般在面试或者笔试基础的时候会问到,其中3个就是map.filter.reduce函数. 1.map(function, iterable) 它第一个要传的元 ...

  5. python中requests库使用方法详解

    目录 python中requests库使用方法详解 官方文档 什么是Requests 安装Requests库 基本的GET请求 带参数的GET请求 解析json 添加headers 基本POST请求 ...

  6. Python Socket套接字编程

    Python 的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语言的一种继承.Py ...

  7. 牛客 26C 手铐 (缩环, 树形dp)

    先缩环建树, 对于树上个环$x,y$, 假设$x,y$路径上有$cnt$个环(不包括$x,y$), 贡献就为$2^{cnt}$. 这题卡常挺严重的, 刚开始用并查集合并竟然T了. #include & ...

  8. 基于bootstrap selectpicker ,实现select下拉框模糊查询功能

    1.html代码块 需要引入bootstrap的css js jquery bootstrap.css bootstrap-select.min.css jquery-1.11.3.min.js bo ...

  9. 如何演讲-摘录自TED

    一.首先,只传递一个主要思想  想法是个很复杂的东西,你要对你的内容做减法,突出重点,只关注一个主要思想,也就是你最富有热情的观点,利用机会好好的阐述它.你要给出案例,分享案例,生动阐述所以,找到一个 ...

  10. 微信小程序修改radio和checkbox的默认样式和图标

    wxml: <view class="body"> <view class="body-content"> 第1题:企业的价值观是 ? ...