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(); C = inpt[0] * 2800; D = inpt[1] * 2800; decimal aCount = GetACount(0, Math.Min(C/21, D/7)); decimal ans = this.GetKingaku(aCount); Console.WriteLine(ans); } private decimal C; private decimal D; private decimal GetACount(decimal min, decimal max) { if(max-min < 0.00000000001m / 28) { return Math.Round(min, 8); } decimal idx1 = min+((max-min)/3); decimal idx2 = max-((max-min)/3); decimal valMin = GetKingaku(min); decimal val1 = GetKingaku(idx1); decimal val2 = GetKingaku(idx2); decimal valMax = GetKingaku(max); decimal mx = new decimal[]{valMin, val1, val2, valMax}.Max(); if(valMin == mx) { return GetACount(min, idx1); } else if(valMax == mx) { return GetACount(idx2, max); } else if(val1 == mx) { return GetACount(min, idx2); } else { return GetACount(idx2, max); } } private decimal GetKingaku(decimal aCount) { /* ・製品Aを作るには1kgあたり薬品Cが34kg、薬品Dが14kg必要である。 ・製品Bを作るには1kgあたり薬品Cが27kg、薬品Dが57kg必要である。 */ decimal nokoriC = this.C - (3*7*aCount); decimal nokoriD = this.D - (1*7*aCount); decimal bCount = Math.Min(nokoriC / (2*4), nokoriD / (5*4)); return aCount * 10 + bCount * 20; } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 5 6 "; 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(); } }