68 - ZOJ Monthly, July 2008 - 1003
The final treasure is about a necklace. And why it is the final one? Because it is the very necklace that Zeus gave it to Hera as a birthday present. What does the necklace look like? You can treat it as a tree, which is made of valuable diamonds. To simplify the problem, mass of the string which between two diamonds can be regarded as 0, and mass of each diamond is 1. And now, it is hanging on the wall in the world's biggest temple. So now the problem is: what is the coordinate of a given diamond?
Each string between two diamonds has a length of 1, and diamond No.0 and No.(N - 1) are the only two points fixed on the wall, they both have equal heights. Diamond No.0's coordinate is (0,0). Now give you the distance between diamond No.0 and No.(N - 1), your task is to calculate the coordinate of diamond No.K.
The input contains multiple test cases!
Each line contains two numbers X, Y (must be rounded off to 3 decimal places), represent the coordinate of the diamond No.K.
3 1 1 1 2 10 2 6 1 2 9 1 1 3 2 6 7
0.500 -0.866 1.500 -1.866
Author: FAN, Yuzhe