#C5297. Sum of Square Roots

    ID: 48930 Type: Default 1000ms 256MiB

Sum of Square Roots

Sum of Square Roots

In this problem, you are given two arrays of non-negative integers, ( arr1 ) and ( arr2 ), each containing ( n ) elements. Your task is to compute a new array ( arr3 ) of length ( n ) where each element is defined by the formula: [ arr3[i] = \sqrt{arr1[i]} + \sqrt{arr2[i]} ] for ( 0 \leq i < n ). The result must be formatted to 4 decimal places for each element.

For example, if ( arr1 = [1, 4, 9, 16] ) and ( arr2 = [1, 4, 9, 16] ), then the output should be:

2.0000 4.0000 6.0000 8.0000

Note: All square root calculations should be performed using the standard square root function available in your language of choice.

inputFormat

The input is given via standard input and consists of three lines:

  • The first line contains an integer ( n ) (( 1 \leq n \leq 10^5 )), which represents the number of elements in each array.
  • The second line contains ( n ) space-separated non-negative integers, representing the elements of ( arr1 ).
  • The third line contains ( n ) space-separated non-negative integers, representing the elements of ( arr2 ).

outputFormat

Output to standard output a single line containing ( n ) numbers. Each number corresponds to ( arr3[i] ) and must be the sum of the square roots of ( arr1[i] ) and ( arr2[i] ), formatted to 4 decimal places. Separate the numbers with a single space.## sample

4
1 4 9 16
1 4 9 16
2.0000 4.0000 6.0000 8.0000