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, , the number of queries.
lines follow, each with a query.
There are 3 query types with vector outputs.
Add queries are in format "
". The answer to this query is the sum of vectors
and
Multiplication queries are in format "
". The answer to this query is the multiplication of vector
and the scalar
Rotation queries are in format "
". The answer to this query is the resulting vector after rotating vector
around the origin by
degrees counterclockwise
There are 3 queries with scalar outputs.
Triangle queries are in format "
". The answer to this query is area of the triangle with points
,
and
Dot product queries are in format "
". The answer to this query is the dot product of vectors
and
Cross product queries are in format "
". The answer to this query is the cross product of vectors
and
All numbers in queries are in range
Output format
For each query, output the answer on a separate line.
For vector outputs, print out the answer in format "
", where
is the horizontal component, and
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, , imported from the iomanip library can resolve this.
Answers within 1e-5 of the reference answer will be accepted.
Examples
Input
3
ADD 3.5 4.5 6 -3
ROT 1 4.5 90
MULT -3892 3 0.5
Output
9.5 1.5
-4.5 1
-1946 1.5
Input
2
TRI 0 0 1 0 0 1
DOT 3000 4000 4000 -3000
Output
0.5
0
Input
1
CROSS -3.5 -6.5 7 13
Output
0
Comments