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<(long, long, int, int)>(); var used = new HashSet<(long, long, int, int)>(); var target = (x: x, y: y, h: h, count: 0); cands.Enqueue(target); used.Add(target); while (cands.Count() > 0) { target = cands.Dequeue(); if(target.x > target.h) { var next = (target.x / 2, target.y, target.h * 2, target.count+1); if(!cands.Contains(next)) { cands.Enqueue(next); used.Add(next); } } if(target.y > target.h) { var next = (target.x, target.y / 2, target.h * 2, target.count+1); if(!cands.Contains(next)) { cands.Enqueue(next); used.Add(next); } } } Console.WriteLine(target.count); } }