PAT B exam "fool" computing solution to a problem of spectral radius

In mathematics, "spectral radius" refers to the matrix of the die set of eigenvalues infimum. In other words, for a given n complex eigenvalue space { A . 1 + B . 1 I , , A n + B n I}, their real part and the mold and prescribing squared imaginary part, while "spectral radius" is the maximum mode.

Now some of the plurality of given spatial feature values, you calculate and output the spectral radius of the eigenvalues.

Input formats:

Input of the first row is given a positive integer N ( ≤ 10 000) is the number of input feature values. Then N rows, each row gives the real and imaginary parts of a characteristic value, separated by a space therebetween. Note: Title ensure real and imaginary part are an integer of not more than the absolute value of 1,000.

Output formats:

Radius line output spectrum, rounded to one decimal place.

Sample input:

5
0 1
2 0
-1 0
3 3
0 -3

Sample output:

4.24
 1 #include<iostream>
 2 #include<cmath>
 3 #include<stdio.h>
 4 using namespace std;
 5 int main()
 6 {
 7     int n;
 8     cin>>n;
 9     int numb[n][2];
10     double max=0;
11     for(int i=0;i<n;i++)
12     {
13         cin>>numb[i][0]>>numb[i][1];
14         double x=numb[i][0]*numb[i][0]+numb[i][1]*numb[i][1];
15         if(sqrt(x)>max)
16         max=sqrt(x);
17     }
18     printf("%.2lf",max);
19     return 0;
20 }

 

Guess you like

Origin www.cnblogs.com/solititude/p/11870301.html