链接:

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. poj2947(高斯消元法解同余方程组)

    题目链接:https://vjudge.net/problem/POJ-2065 题意:题目看着较复杂,实际上就是给了n个同余方程,解n个未知数. 思路:套高斯消元法的模板即可. AC代码: #inc ...

  2. postgresSQL常用命令

    1.createdb 数据库名称  产生数据库2.dropdb  数据库名称  删除数据库 3.CREATE USER 用户名称  创建用户4.drop User 用户名称  删除用户 5.SELEC ...

  3. 处理vue页面406问题纪要

    1.servlet-mapping url-pattern / 与 /* 的区别注意关注 2.mvc:resource 是否生效,注意关注,如不生效,可在 web.xml中配置<servlet- ...

  4. TeX教程

    转自 [抢工作向]一个更适合玩物理的同学的论坛TeX教程 1. 基础知识 如何在你的帖子里插入一个\(\TeX\)环境来写公式呢?答案其实很简单,对于不同的要求,我们有两种方法. 第一种只需要在\(\ ...

  5. centos7 宝塔php7安装mongodb扩展

    一.下载.解压源码 下载地址:https://pecl.php.net/package/mongodb wget -c https://pecl.php.net/get/mongodb-1.5.3.t ...

  6. 【leetcode】【二分 | 牛顿迭代法】69_Sqrt(x)

    题目链接:传送门 题目描述: 求Sqrt(x),返回整数值即可. [代码]: #include<bits/stdc++.h> using namespace std; ; /* int m ...

  7. k8s-helm安装

      kubernetes 1.15安装部署helm插件 简单介绍: Helm其实就是一个基于Kubernetes的程序包(资源包)管理器,它将一个应用的相关资源组织成为Charts,并通过Charts ...

  8. 怎样获取当前文档所有的元素节点(即html标签节点)

    方法1. 使用 document.getElementsByTagName("*"); 方法2. 使用document.querySelectorAll("*" ...

  9. 《精通Windows API-函数、接口、编程实例》——第4章文件系统

    第4章文件系统 4.2 磁盘和驱动器管理 文件系统的基本概念:包括磁盘分区,卷,目录,文件对象,文件句柄,文件映射1.磁盘分区:物理磁盘,逻辑磁盘2.卷:也称逻辑驱动器,是NTFS,FAT32等文件系 ...

  10. Windows 软件使用

    1.CMD 1. 查看端口对应进程 netstat -ano|findstr "443" 2.通过PID 查找对应进程 tasklist|findstr “<PID号> ...