using System; using System.Collections.Generic; using System.Linq; public class P1010 { public static void Main() { var xyh = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToList(); var x = xyh[0] * 1000L; var y = xyh[1] * 1000L; var h = xyh[2]; var cands = new Queue<(int, int, int)>(); var used = new HashSet<(int, int, int)>(); var target = (x: 0, y: 0, h: h); cands.Enqueue(target); used.Add(target); while (cands.Count() > 0) { target = cands.Dequeue(); if(x > target.h * (1 << target.x)) { var next = (target.x + 1, target.y, target.h * 2); if(!cands.Contains(next)) { cands.Enqueue(next); used.Add(next); } } if(y > target.h * (1 << target.y)) { var next = (target.x, target.y + 1, target.h * 2); if(!cands.Contains(next)) { cands.Enqueue(next); used.Add(next); } } } Console.WriteLine(target.x + target.y); } }