13066 - Complex Number Structure   

Description

This is a partial judge problem.
In this problem, you're asked to implement the following function that related to complex number arithmetic.

typedef struct {
	long long real;
	long long imag; 
} Complex;

First you have a struct binded with two integers which is the real part and imaginary part of a complex number. 

Complex CreateComplex(long long, long long);

Return a complex number that its real part is the first parameter and its imaginary part is the second parameter. 

Complex Add(Complex, Complex);
Complex Sub(Complex, Complex);
Complex Mul(Complex, Complex);

For the above three functions, you have to return the result of doing the corresponding calculation.
Add stands for addition, Sub stands for subtraction, Mul stands for Multiplication.

void Compare(Complex*, Complex*);

For the above function, we compare the absolute value of two complex number. If the absolute value of the first parameter is less than the absolute value of the second parameter, swap them. That it, after executing Compare() function, guarentee that the first parameter has the greater absolute value, and if the absolute value are the same, do nothing.

For more information, you can refer to the source code.

Note:

Addition Rule: (a + bi) + (c + di) = (a + c) + (b + d)i
Subtraction Rule: 
(a + bi) - (c + di) = (a - c) + (b - d)i
Multiplication Rule: (a + bi) · (c + di) = (ac - bd) + (cb + ad)i

 

Input

First line of the input contains one integer T (T <= 100000), representing the number of operation.
Next, input T lines. Each line contains one integer and two complex numbers.
The integer indicates which function to use.
Guarentee the real and imag of the input complex number are integers and they're in range of [-1000000, 1000000] .
For detail input format, you can refer to the source code.

Output

Output the calculation result for each operation.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13066.c

Partial Judge Header

13066.h

Tags




Discuss