题目链接:点击查看

题目大意:给出一个n*n的矩阵,初始时有一个数组a,矩阵中的每个M[i][j]=a[i]*a[j],现在对角线缺失,需要我们构造一种数组a的情况

题目分析:其实稍微分析一下就能看出,只要知道其中的一个a[k],其他的就都知道了

因为M[i][j]=a[i]*a[j],我们可以用M[i][j]*M[j][k]/M[j][k]来计算出a[i]*a[i]的值,然后问题就解决了

代码:

#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cctype>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<sstream>
using namespace std;typedef long long LL;const int inf=0x3f3f3f3f;const int N=1e3+100;int maze[N][N],ans[N];int main()
{
//  freopen("input.txt","r",stdin);
//  ios::sync_with_stdio(false);int n;scanf("%d",&n);for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)scanf("%d",&maze[i][j]);ans[1]=sqrt(1LL*maze[1][2]*maze[1][3]/maze[2][3]);for(int i=2;i<=n;i++)ans[i]=maze[i][1]/ans[1];for(int i=1;i<=n;i++)printf("%d ",ans[i]);return 0;
}

CodeForces - 1220B Multiplication Table(思维)相关推荐

  1. codeforces 577A Multiplication Table【思维】

    codeforces 577A Multiplication Table Let's consider a table consisting of n rows and n columns. The ...

  2. Codeforces Round #586 (Div. 1 + Div. 2) B. Multiplication Table 思维 + 公式

    传送门 文章目录 题意: 思路: 题意: 给你一个n∗nn*nn∗n的矩阵,每个位置由ai∗aja_i*a_jai​∗aj​得来,主对角线为000,让你求出来aia_iai​. n≤1e3n\le1e ...

  3. C - Multiplication Table CodeForces - 448D

    C - Multiplication Table CodeForces - 448D 题目: Problem Description Bizon the Champion isn't just cha ...

  4. Codeforces Codeforces Round #319 (Div. 2) A. Multiplication Table 水题

    A. Multiplication Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/57 ...

  5. Codeforces Round #256 (Div. 2) D Multiplication Table

    Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the mu ...

  6. LeetCode hard 668. Kth Smallest Number in Multiplication Table(二分答案)

    题目:https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/description/ Kth Smalle ...

  7. CodeForces - 1593G Changing Brackets(思维)

    题目链接:点击查看 题目大意:给出一个长度为 nnn 的括号序列,其中包含了 {(,),[,]}\{(,),[,]\}{(,),[,]} 四种括号,现在可以进行两种操作: 将括号反转,代价为 000, ...

  8. CodeForces - 1567C Carrying Conundrum(思维/状压)

    题目链接:点击查看 题目大意:规定加法中使用隔项进位,问给定的 nnn 有多少种方案可以通过 "隔项进位加法" 得到 题目分析:隔项进位意味着奇偶位置的数字互不影响,所以将奇偶位置 ...

  9. CodeForces - 1535C Unstable String(思维)

    题目链接:点击查看 题目大意:规定一个字符串将问号都替换成 000 或 111 后满足 010101 交替的话,该字符串是合法的,现在给出一个长度为 nnn 的字符串,求合法子串的个数 题目分析:两种 ...

最新文章

  1. 用Everything搜索指定的路径
  2. PHP 实现代码复用的一个方法 traits新特性
  3. mysql dba系统学习(4)mysql的多实例multi启动停止
  4. 处理100万条数据 python_使用 Python 处理3万多条数据只要几秒钟
  5. 基于JAVA+SpringBoot+Mybatis+MYSQL的新闻发布系统
  6. Springmvc提供的传递数据的方式
  7. awk 查看ip连接数(常见应用一)
  8. 【Android】雾霾定位探测系统
  9. 注意力缺陷障碍可以通过​训练大脑来管理
  10. OpenWrt自定义luci页面来修改配置文件
  11. 程序人生 -- 我的成长之路和进阶经验分享
  12. 《基于MFC的OpenGL编程》Part 7 Animation
  13. Java实现魔板拼图小游戏(完整版)
  14. 百胜中国拟2025年前开1000家Lavazza咖啡店​;别样肉客开始陆续进驻中国山姆会员商店 | 知消...
  15. 树莓派智能家居homeassistant之homekit篇
  16. 如何云同步敬业签待办事项任务?
  17. 杭州千岛湖|杭州千岛湖风景介绍|杭州千岛湖景点介绍
  18. linux 上传文件rz -bye
  19. 《微信公众平台开发最佳实践》——导读
  20. sqli-labs系列——第一关

热门文章

  1. oracle 获取系统年 月,Oracle 获取当前年、月、日
  2. MySQL高级 - 案例 - AOP记录日志
  3. 一条更新SQL 是如何执行的?
  4. Java Virtual Machine Stacks(虚拟机栈)
  5. Elastic-Job中的DataFlowJob
  6. Java中常见的日志框架
  7. RequestMapping介绍
  8. MyDataSourceUtils使用ThreadLocal对象
  9. JavaScript中替换字符串中的所有小数点
  10. java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind