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