问题描述:
在数学中,矩阵的“谱半径”是指其特征值的模集合的上确界。换言之,对于给定的 n 个复数空间的特征值 { a1+b1i,⋯,an+bni },它们的模为实部与虚部的平方和的开方,而“谱半径”就是最大模。现在给定一些复数空间的特征值,请你计算并输出这些特征值的谱半径。
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {int n;
scanf("%d",&n);double s[n];for(int i=0; i<n; ++i) {int a,b;
scanf("%d %d",&a,&b);s[i]=sqrt(pow(a,2)+pow(b,2));}
sort(s,s+n);
printf("%.2lf\n",s[n-1]);return 0;
}