TRIPLE ARITHMETIC

All submissions for this problem are available.
TRIPLE ARITHMETIC
The CGBSE
Board has decided to introduce TRIPLES as a part of their Curriculum of High
School. They believe this will make it easier for students to learn Coordinate
Geometry and Calculus easily.
Any Triple
of the form a,b,c represents
a right angled triangle with Base = a; Height = b; Hypotenuse = C. Hence any
triple represents an angle A such that cosA = a/c.
A Triple is called
a Prime Triple if its elements are whole number and have no common factor. For example
(3, 4, 5) and (24, 7, 25) are Prime Triples. However, (6, 8 10) is not because
2 is a common Factor.
The very
basic Triple Arithmetic includes addition of Angles of Triple, i.e. if a1,a2,a3
define angle A and b1,b2,b3 define angle B then you need to find Prime Triple corresponding to angles
A+B or AB.
©Vishal
Gupta
Input:
Input contains a number of test
cases. Each test case contains 3 lines.
First Line contains either ‘+’ or
‘‘.
Second Line contains Triple for angle
A a1,a2,a3
Third Line contains Triple for Angle
B b1,b2,b3
Output:
If the input is +,
you need to output the Prime Triple Corresponding to angle A+B.
If the input is ,
you need to output the Prime Triple Corresponding to angle AB.
Input:
+
4 3 5
15 8 17

4 3 5
3 4 5
+
3 4 5
3 4 5
+
1 0 1
0 1 1
Sample Output:
36 77 85
24 7 25
7 24 25
0 1 1
Author:  ganesha 
Tags  ganesha 
Date Added:  28032010 
Time Limit:  0.291667 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 