链接:

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. 【AtCoder】AGC004

    AGC004 A - Divide a Cuboid 看哪一维是偶数,答案是0,否则是三个数两两组合相乘中最小的那个 #include <bits/stdc++.h> #define fi ...

  2. Kubernetes---启动及退出动作

    apiVersion: v1 kind: Pod metadata: name: lifecycle-demo spec: containers: - name:lifecycle-demo-cont ...

  3. pthread_cond_t

    条件锁pthread_cond_t (1)pthread_cond_wait的使用 等待线程1. 使用pthread_cond_wait前要先加锁2. pthread_cond_wait内部会解锁,然 ...

  4. 数据库优化方案之SQL脚本优化

    随着数据库数据越来越大,数据单表存在的数据量也就随之上去了,那么怎么样让我们的脚本查询数据更快呢? 在这个地方我们主要提到两个数据库类型: 1.MSSQL(该数据库我们通过执行计划来查看数据库性能在哪 ...

  5. C语言存30位数字长的十进制方法

    题目:将一个长度最多为30位数字的十进制非负整数转换为二进制数输出. 首先: 1,30位数字的十进制,并没有一个数据类型可以存下30位的整数类型数字,所以考虑用字符串存储这个数据,遍历这个字符串,每个 ...

  6. 常用javascript对象——Date对象

    创建 Date 对象的语法: new Date(); 1:Date 对象属性 <!DOCTYPE html> <html> <head> <meta char ...

  7. WebStorm 2017 最新激活方式

    刚开始使用WebStorm注册时,在打开的License Activation窗口中选择“activation code”,在输入框输入下面的注册码 43B4A73YYJ-eyJsaWNlbnNlSW ...

  8. Django中 auto_now_add 和 auto_now 的区别

    auto_now_add = True #创建时添加的时间 修改数据时,不会发生改变 auto_now = True #修改数据的时间,每次修改都会有变动 ........

  9. Cron 表达式详解

    Crontab Crontab简介 crontab命令常见于Unix和类Unix的操作系统之中,用于设置周期性被执行的指令.该命令从标准输入设备读取指令,并将其存放于"crontab&quo ...

  10. JS的一些简单基础运算题

    1.输入一个四位数,在控制台分别显示个位,十位,百位,千位的数值 var a = prompt("请输入一个四位数的正整数"); var b = parseInt(a/1000); ...