問題一覧 > 通常問題

No.450 ベー君のシャトルラン

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-6}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 279
作問者 : arukuka
お気に入りにしたユーザー ProblemId : 1434 / 自分の提出
問題文最終更新日: 2026-06-25 08:57:12
Bee-kun's Shuttle Run
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Advent Calendar Contest 2016 (順位表) の他の問題:

This problem is the Day 1 problem of Advent Calendar Contest 2016.

Problem Statement

Bee-kun the bee loves shuttle runs and looks forward to his school's physical fitness test every year.

One day, in order to improve his shuttle run record, Bee-kun came up with the following training method.

  1. Find a train on the left running rightward at speed $v_l$ [m/s], and a train on the right running leftward at speed $v_r$ [m/s].
  2. At this moment, the two trains face each other and are a distance $d$ [m] apart.
  3. At $t = 0$, Bee-kun starts from the front of the left train, heading right at speed $w$ [m/s].
  4. When he reaches the front of the right train, he touches it and turns back to the left.
  5. When he reaches the front of the left train, he touches it and turns back to the right.
  6. He repeats steps 4-5 until the two trains pass each other, and then finishes.

After finishing the training, Bee-kun wanted to know how far he had traveled.

Calculate the total distance traveled [m] for Bee-kun.

Note that:

  • Bee-kun moves faster than the two trains,
  • the positions of the two trains can be represented on the x-axis, and all other spatial distances are regarded as 0,
  • Bee-kun moves parallel to the ground, and
  • the time taken to touch is negligible.

Input

$v_l$ $v_r$
$d$
$w$

$ 1 \leq v_l, v_r \leq 10^9, v_l, v_r \in \mathbb{N} $

$ 1 \leq d \leq 10^9, d \in \mathbb{N}$

$ 1 \leq w \leq 10^9, w \in \mathbb{N} $

$ \max \{ v_l, v_r \} < w $

Output

Output Bee-kun's total distance traveled [m]. Print a newline at the end.

The output is accepted if the absolute error or relative error is at most $10^{−6}$.

Sample

Sample 1
Input
1 1
6
2
Output
6

This is the initial state.

When he touches the right train for the first time, Bee-kun has moved 4 [m].

When he turns back and touches the left train, Bee-kun has moved $\frac{4}{3}$ [m].

Since this repeats, the answer is $\sum_{n=0}^{\infty} \frac{4}{3^n} = 6$.

Sample 2
Input
1 3
12
7
Output
21

Sample 3
Input
90 568
5019
870
Output
6636.0638297

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。