using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "Input3"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("1 1 150 200"); //300 //コーヒー150mlと紅茶150mlから //300mlの鴛鴦茶を作ることができます。 } else if (InputPattern == "Input2") { WillReturn.Add("4 6 150 200"); //333.333333333333 //コーヒー400/3 mlと //紅茶200mlから //1000/3 mlの鴛鴦茶を作ることができます。 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); decimal[] wkArr = InputList[0].Split(' ').Select(X => decimal.Parse(X)).ToArray(); decimal RateCoffee = wkArr[0]; decimal RateKoutya = wkArr[1]; decimal Coffee = wkArr[2]; decimal Koutya = wkArr[3]; //コーヒーを全て使う場合 decimal NeedKoutya = Coffee / RateCoffee * RateKoutya; if (NeedKoutya <= Koutya) { Console.WriteLine(Coffee + NeedKoutya); return; } //紅茶を全て使う場合 decimal NeedCoffee = Koutya / RateKoutya * RateCoffee; Console.WriteLine(Koutya + NeedCoffee); } }