Codeforces Beta Round 34(Div. 2)
E
碰撞
Collisions
Codeforces
2000
原题
← D→

碰撞AI (CI翻译)

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.

在数轴上有 $*n*$ 个小球。对于每个小球,已知其在时刻 $0$ 的以下数据:坐标 $*x*_{*i*}$、速度 $*v*_{*i*}$(可能为负)以及质量 $*m*_{*i*}$。可以忽略小球的半径。AI (CI翻译)

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:

小球之间会发生弹性碰撞,即如果质量分别为 $*m*_{1}$ 和 $*m*_{2}$、速度分别为 $*v*_{1}$ 和 $*v*_{2}$ 的两个小球发生碰撞,那么它们的新速度将为:AI (CI翻译)

image

imageAI (CI翻译)

.

。AI (CI翻译)

Your task is to find out, where each ball will be $*t*$ seconds after.

你的任务是求出 $*t*$ 秒后每个小球所在的位置。AI (CI翻译)

Input

输入格式

AI (CI翻译)

The first line contains two integers $*n*$ and $*t*$ ($1 ≤ *n* ≤ 10, 0 ≤ *t* ≤ 100$) — amount of balls and duration of the process. Then follow $*n*$ lines, each containing three integers: $*x*_{*i*}$, $*v*_{*i*}$, $*m*_{*i*}$ ($1 ≤ |*v*_{*i*}|, *m*_{*i*} ≤ 100, |*x*_{*i*}| ≤ 100$) — coordinate, speed and weight of the ball with index $*i*$ at time moment $0$.

第一行包含两个整数 $*n*$ 和 $*t*$($1 ≤ *n* ≤ 10, 0 ≤ *t* ≤ 100$),分别表示小球的数量和过程持续时间。接下来有 $*n*$ 行,每行包含三个整数:$*x*_{*i*}$、$*v*_{*i*}$、$*m*_{*i*}$($1 ≤ |*v*|, *m* ≤ 100, |*x*| ≤ 100$),分别表示编号为 $*i*$ 的小球在时刻 $0$ 的坐标、速度和质量。AI (CI翻译)

It is guaranteed that no two balls have the same coordinate initially. Also each collision will be a collision of not more than two balls (that is, three or more balls never collide at the same point in all times from segment $[0;*t*]$).

保证初始时没有两个小球具有相同的坐标。此外,每次碰撞涉及的小球数不超过两个(即在时间区间 $[0;*t*]$ 内,不会有三个或更多小球在同一点发生碰撞)。AI (CI翻译)

Output

输出格式

AI (CI翻译)

Output $*n*$ numbers — coordinates of the balls $*t*$ seconds after. Output the numbers accurate to at least 4 digits after the decimal point.

输出 $*n*$ 个数,表示 $*t*$ 秒后各个小球的坐标。输出结果的小数点后至少要有 4 位数字。 AI (CI翻译)

样例

Input #1
2 9
3 4 5
0 7 8
Output #1
68.538461538
44.538461538
InputCopy OutputCopy
Input #2
3 10
1 2 3
4 -5 6
7 -8 9
Output #2
-93.666666667
-74.666666667
-15.666666667
InputCopy OutputCopy
题目信息
题号
34E
时间限制
2 s
内存限制
256 MB
标签
暴力
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。