PAT (Basic Level) Practise (中文) 1063. 计算谱半径(20)
来源:互联网 发布:ae 编程 编辑:程序博客网 时间:2024/06/18 07:20
1063. 计算谱半径(20)
时间限制
200 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
在数学中,矩阵的“谱半径”是指其特征值的模集合的上确界。换言之,对于给定的n个复数空间的特征值{a1+b1i, ..., an+bni},它们的模为实部与虚部的平方和的开方,而“谱半径”就是最大模。
现在给定一些复数空间的特征值,请你计算并输出这些特征值的谱半径。
输入格式:
输入第一行给出正整数N(<= 10000)是输入的特征值的个数。随后N行,每行给出1个特征值的实部和虚部,其间以空格分隔。注意:题目保证实部和虚部均为绝对值不超过1000的整数。
输出格式:
在一行中输出谱半径,四舍五入保留小数点后2位。
输入样例:50 12 0-1 03 30 -3输出样例:
4.24
/*
* 测试点2超时 部分正确16分* 思路
* 这道题一开始把人唬住了,什么实部虚部的,其实题意就是
* 输入的第一个数n为行数
* 接下来录入n行数据,每行两个数字
* 求每组数平方和的开根号
* 找出最大的那个,然后四舍五入保留两位小数
*/
import java.util.Scanner;
public class num1063 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int n=input.nextInt();
int max=-1;
for (int i = 0; i < n; i++) {
int temp1=input.nextInt();
int temp2=input.nextInt();
int sum=temp1*temp1+temp2*temp2;
if (max<sum) {
max=sum;
}
}
System.out.printf("%.2f",Math.sqrt(max));
//System.out.printf("%.2f",4.245);
}
}
/*C++ac
* //#include <cmath> 等价于c #include<math.h>
#include <iostream>
#include <cmath>
#include<stdio.h>//用printf必须导入这个头
using namespace std;
* int main(){
int n;
cin>>n;
int max=-1;
for (int i = 0; i < n; i++) {
int temp1,temp2;
cin>>temp1>>temp2;
int sum=temp1*temp1+temp2*temp2;
if (max<sum) {
max=sum;
}
}
float result=sqrt(max);
printf("%.2f",result);
return 0;
}
*/
阅读全文
0 0
- PAT (Basic Level) Practise (中文) 1063. 计算谱半径(20)
- PAT (Basic Level) Practise (中文)1063. 计算谱半径(20)
- PAT BASIC LEVEL 1063. 计算谱半径(20)
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)--1001
- PAT (Basic Level) Practise (中文)
- PAT (Basic Level) Practise (中文)1001
- PAT (Basic Level) Practise (中文)1002
- PAT (Basic Level) Practise (中文) 1007
- PAT (Basic Level) Practise (中文) 1077. 互评成绩计算 (20)
- PAT (Basic Level) Practise (中文)1004. 成绩排名 (20)
- PAT (Basic Level) Practise (中文)1009. 说反话 (20)
- PAT (Basic Level) Practise (中文)1012. 数字分类 (20)
- PAT (Basic Level) Practise (中文)1013. 数素数 (20)
- PAT (Basic Level) Practise (中文)1019. 数字黑洞 (20)
- PAT (Basic Level) Practise (中文)1027. 打印沙漏(20)
- PAT (Basic Level) Practise (中文)1028. 人口普查(20)
- 应用层-3、web缓存和代理服务器技术
- python3种编辑方法
- keras读取model进行人脸预测
- float:left和display:inline一起用
- POJ
- PAT (Basic Level) Practise (中文) 1063. 计算谱半径(20)
- 数组的概念,定义格式,取值,赋值以及数组的初始化
- struts2的工作原理 及优缺点
- 跳台阶
- nginx安装,配置、虚拟主机、轮询、域名重定向
- 【C#】枚举类型Enum与状态设计模式
- 原生js和canvas实现的 柱状图、饼状图、折线图
- Python中的raw_input() 与 input()
- Machine Learning From Scratch-从头开始机器学习