587 - There's treasure everywhere!
Solution Description : 2D geometry problem The tricky part of the problem is parsing the input. For N direction add the value to y For E direction add the value to x For S direction subtract value from y For W direction subtract value from x For NE direction add the value to x and y For SE direction add the value to x and subtract the value from y For SW direction subtract the value from x and y For NW direction subtract the value form x and add the value to y For all diagonal direction you need to multiply 1/sqrt(2) before add or subtraction. do not need to use long double. At the end print (x,y) and sqrt(x*x+y*y) Remember print a blank line for each output set |
||||||||||