#K41802. Vector Magnitude in n-Dimensional Space
Vector Magnitude in n-Dimensional Space
Vector Magnitude in n-Dimensional Space
Compute the magnitude of a vector in ( n )-dimensional space. Given a vector with components ( x_1, x_2, \dots, x_n ), the magnitude is computed as ( \sqrt{x_1^2 + x_2^2 + \dots + x_n^2} ). You need to calculate this magnitude given the vector components and output the result rounded to two decimal places.
Note: If the result is an integer, it must be printed with one decimal place (for example, 5.0).
inputFormat
The first line contains an integer ( n ), the number of dimensions. The second line contains ( n ) space-separated integers representing the components of the vector.
outputFormat
Output the magnitude of the vector rounded to two decimal places. If the result is an integer, print it with one decimal place (e.g., 5.0).## sample
2
3 4
5.0