Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/suvlarni-aralashtirish

Mixing water

Easy 1000 ms 64 MB 11%
Share

$m_{2}$ kg of water at $t_{2}$ degrees is poured into $m_{1}$ kg of water at $t_{1}$ degrees. No heat is lost. Find the temperature $t$ of the mixture:

$$t = \frac{m_{1} * t_{1} + m_{2} * t_{2}}{m_{1} + m_{2}}$$

Water in two vessels: one with mass m1 and temperature t1, the other with mass m2 and temperature t2; they are poured into one vessel and the mixture temperature t is found

Input

One line with four integers: $m_{1}$, $t_{1}$, $m_{2}$ and $t_{2}$.

Output

One number — $t$, with exactly 2 digits after the decimal point (for example, 35.71).

Note

$1 \le m_{1}, m_{2} \le 1000$
$0 \le t_{1}, t_{2} \le 100$

Examples

Input #1
2 80 3 20
Output #1
44.00
Input #2
3 70 4 10
Output #2
35.71

Sign in to submit a solution

Signing up is free and takes a minute.