CF34E Collisions
Description
On a number line there are $ n $ balls. At time moment $ 0 $ for each ball the following data is known: its coordinate $ x_{i} $ , speed $ v_{i} $ (possibly, negative) and weight $ m_{i} $ . The radius of the balls can be ignored.
The balls collide elastically, i.e. if two balls weighing $ m_{1} $ and $ m_{2} $ and with speeds $ v_{1} $ and $ v_{2} $ collide, their new speeds will be:
.Your task is to find out, where each ball will be $ t $ seconds after.
Input Format
The first line contains two integers $ n $ and $ t $ ( $ 1
Output Format
Output $ n $ numbers — coordinates of the balls $ t $ seconds after. Output the numbers accurate to at least 4 digits after the decimal point.