当前位置:网站首页>[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius
[pat (basic level) practice] - [simple simulation] 1063 calculate the spectral radius
2022-07-03 04:15:00 【IronmanJay】
List of articles
One 【 questions 】
- Class B
Two 【 Title number 】
- 1063 Calculate the spectral radius (20 branch )
3、 ... and 【 Title Description 】
- In mathematics , Matrix “ Spectral radius ” Is the supremum of the modular set of its eigenvalues . In other words , For a given n n n Eigenvalues of a complex space a 1 + b 1 i , ⋯ , a n + b n i { a_1+b_1 i,⋯,a_n +b_n i } a1+b1i,⋯,an+bni, Their modules are the square of the sum of squares of real and imaginary parts , and “ Spectral radius ” Is the maximum module .
- Now let's give some eigenvalues of complex space , Please calculate and output the spectral radius of these eigenvalues .
Four 【 Title Example 】
Input format :
Enter the first line to give a positive integer N(≤ 10 000) Is the number of input eigenvalues . And then N That's ok , Each line gives 1 The real and imaginary parts of eigenvalues , Separated by spaces . Be careful : The problem is to ensure that both the real part and the imaginary part are absolute values that do not exceed 1000 The integer of .Output format :
Output the spectral radius in one line , Round to decimal 2 position .sample input :
5
0 1
2 0
-1 0
3 3
0 -3sample output :
4.24
5、 ... and 【 Their thinking 】
- The first thing that came to my mind , According to the requirements of the topic, the analog output is then calculated and stored in the array , Then sort the array from large to small , The first is the output , But there are always two use cases that fail , You have to 14 branch , I didn't think about the specific reason . Later, it was found that there was no need for storage , Because we just need to find the biggest , So first set up m a x = 0 max=0 max=0, Because the smallest is 0 0 0, If the result of analog operation is better than m a x max max Big update , After traversing the output data, you can get the final result
6、 ... and 【 The final score 】
- 20 branch
7、 ... and 【 Code implementation 】
#include<stdio.h>
#include<math.h>
int main()
{
int n;
scanf("%d",&n);
double max = 0;
for(int i = 0;i<n;i++)
{
double n1,n2;
scanf("%lf %lf",&n1,&n2);
double temp = sqrt(pow(n1,2) + pow(n2,2));
if(temp > max)
{
max = temp;
}
}
printf("%.2lf",max);
return 0;
}
8、 ... and 【 Submit results 】

边栏推荐
- MySQL field userid comma separated save by userid query
- 毕设-基于SSM宠物领养中心
- Fcpx template: sweet memory electronic photo album photo display animation beautiful memory
- Basic types of data in TS
- Social phobia of contemporary young people (II)
- js/ts底层实现双击事件
- Write it down once Net travel management background CPU Explosion Analysis
- [set theory] inclusion exclusion principle (including examples of exclusion principle)
- Idea shortcut keys
- Wechat applet + Alibaba IOT platform + Hezhou air724ug built with server version system analysis
猜你喜欢

How does the pytorch project run?

Database management tool, querious direct download

解决bp中文乱码

2022 tea master (intermediate) examination questions and analysis and tea master (intermediate) practical examination video

2022 polymerization process examination questions and polymerization process examination skills

2022 P cylinder filling examination content and P cylinder filling practice examination video

redis 持久化原理

『期末复习』16/32位微处理器(8086)基本寄存器

Appium自动化测试框架

Mutex and rwmutex in golang
随机推荐
Practical operation of vim
MySQL timestampdiff interval
2022 P cylinder filling examination content and P cylinder filling practice examination video
[Blue Bridge Road -- bug free code] DS18B20 temperature reading code analysis
[set theory] set concept and relationship (set represents | number set | set relationship | contains | equality | set relationship property)
[set theory] inclusion exclusion principle (including examples of exclusion principle)
2022-07-02: what is the output of the following go language code? A: Compilation error; B:Panic; C:NaN。 package main import “fmt“ func main() { var a =
Wechat applet + Alibaba IOT platform + Hezhou air724ug built with server version system analysis
Interaction free shell programming
[no title] 2022 chlorination process examination content and free chlorination process examination questions
The time has come for the domestic PC system to complete the closed loop and replace the American software and hardware system
Is pytorch open source?
GFS分布式文件系统(光是遇见已经很美好了)
In Net 6 project using startup cs
以两列的瀑布流为例,我们应该怎么构建每一列的数组
What are the Bluetooth headsets with good sound quality in 2022? Inventory of four high-quality Bluetooth headsets
Social phobia of contemporary young people (III)
2022deepbrainchain biweekly report no. 104 (01.16-02.15)
[untitled] 2022 safety production supervisor examination question bank and simulated safety production supervisor examination questions
Database management tool, querious direct download