Back
Close

The absolute value of Complex Numbers

Statement

 Goal

Write a program that prints the absolute value of a given Complex number.
|3 + 4i| = 5
|-2 + 3i| = sqrt(13)
Input
Line 1: A Complex number -2 + 3i
Output
Line 1:If not a perfect square sqrt(13) or 5 if perfect square. 4*sqrt(3) while mathematically valid print sqrt(48) instead
Constraints
Line 1: ≤ 2^32.
Example
Input
3 + 4i
Output
5

Game modes
Fastest, Shortest, Reverse

Test cases
Test 1 Test
Input
3 + 4i
Output
5

Validator 1 Validator
Input
-2 + 3i
Output
sqrt(13)

Test 2 Test
Input
5 + 12i
Output
13

Validator 2 Validator
Input
11 - 60i
Output
61

Test 3 Test
Input
0 - 0i
Output
0

Validator 3 Validator
Input
-1 - 0i
Output
1

Max int Test
Input
-3 - 5i
Output
sqrt(34)

Validator 4 Validator
Input
-3 - 66i
Output
sqrt(4365)

Solution language

Solution

Stub generator input