Vector Calculator


Vector Calculator

Listen up soldier! You are going into the front lines, maggot! I don't wanna hear about "integers" or "real numbers anymore". Drop and give me twenty, and then implement a calculator that can calculate 2d vector operations!!!!!!.

Input format

The first line has one integer, nn, the number of queries.

nn lines follow, each with a query.

There are 3 query types with vector outputs.

Add queries are in format "ADDADD axa_x aya_y bxb_x byb_y". The answer to this query is the sum of vectors (ax,ay)(a_x, a_y) and (bx,by)(b_x, b_y)

Multiplication queries are in format "MULTMULT axa_x aya_y bb". The answer to this query is the multiplication of vector (ax,ay)(a_x, a_y) and the scalar bb

Rotation queries are in format "ROTROT axa_x aya_y angang". The answer to this query is the resulting vector after rotating vector (ax,ay)(a_x, a_y) around the origin by angang degrees counterclockwise

There are 3 queries with scalar outputs.

Triangle queries are in format "TRITRI axa_x aya_y bxb_x byb_y cxc_x cyc_y". The answer to this query is area of the triangle with points (ax,ay)(a_x,a_y), (bx,by)(b_x,b_y) and (cx,cy)(c_x,c_y)

Dot product queries are in format "DOTDOT axa_x aya_y bxb_x byb_y". The answer to this query is the dot product of vectors (ax,ay)(a_x, a_y) and (bx,by)(b_x, b_y)

Cross product queries are in format "CROSSCROSS axa_x aya_y bxb_x byb_y". The answer to this query is the cross product of vectors (ax,ay)(a_x, a_y) and (bx,by)(b_x, b_y)

1<n<1e51 < n < 1e5

All numbers in queries are in range [−1e5,1e5][-1e5, 1e5]

Output format

For each query, output the answer on a separate line. For vector outputs, print out the answer in format "xx yy", where xx is the horizontal component, and yy is the vertical component For scalar outputs, simply print out the answer in a separate line.

Tip: be careful of the print format, we don't the program to print in scientific form, or to be skimping out on decimal places. For c++ users, cout<<setPrecision(10)cout << setPrecision(10), imported from the iomanip library can resolve this.

Answers within 1e-5 of the reference answer will be accepted.

Examples

Input 1
3
ADD 3.5 4.5 6 -3
ROT 1 4.5 90
MULT -3892 3 0.5
Output 1
9.5 1.5
-4.5 1
-1946 1.5

Input 2
2
TRI 0 0 1 0 0 1
DOT 3000 4000 4000 -3000
Output 2
0.5
0
Input 3
1
CROSS -3.5 -6.5 7 13
Output 3
0

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.