using System; using System.Linq; using System.Text; using System.Collections.Generic; public class Program { public void Proc() { Reader.IsDebug = false; decimal[] inpt = Reader.ReadLine().Split(' ').Select(a=>decimal.Parse(a)).ToArray(); this.V1 = inpt[0]; this.V2 = inpt[1]; this.D = decimal.Parse(Reader.ReadLine()); this.W = decimal.Parse(Reader.ReadLine()); decimal ans = Math.Round(GetAns(0, D, true), 7); Console.WriteLine(ans); } private decimal GetAns(decimal v1Pos, decimal v2Pos, bool isLeft) { decimal diff = v2Pos - v1Pos; if(diff < 0.000000001m) { return diff; } decimal pos = 0; if(isLeft) { pos = diff / (V2 + W) * W; decimal nextV1 = pos / W * V1; decimal nextV2 = pos; return GetAns(nextV1, nextV2, !isLeft) + pos; } else { decimal mv = (diff / (V1 + W) * W); decimal nextV1 = v2Pos - mv; decimal nextV2 = v2Pos - (mv / W * V2); return GetAns(nextV1, nextV2, !isLeft) + mv; } } private decimal V1; private decimal V2; private decimal D; private decimal W; public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 90 568 5019 870 "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }