Complex Numbers
Time limit0.5sMemory limit512 MB
Given two complex numbers written as (b + c*sqrt(d))/a with a shared squarefree d, print their sum, difference, product, and quotient in the same reduced canonical form.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Implementation, Simulation
- Solved
- No attempts yet
Problem
-
-
For :
- are integers
- ;
- '' if and only if ''
- When , has no square divisor greater than
-
Given complex numbers and written in the form above, write a program that prints the values of , , , and .
Input
The first line gives the values of , one per position.
The second line gives the values of in the same way.
Output
Print four lines. Line one through line four hold the values for , , , and , each expressed in the form described in the problem statement.
Constraints
- and have the same value of
- The input satisfies the conditions of the form described in the problem statement
- Every number in the input has absolute value at most