require 'bigdecimal' class Calc0168 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @n = args.shift.first.to_i @xys = args.map { |l| l.map(&:to_i) } end def calc graph = [] (0...@n).each do |i| ((i + 1)...@n).each do |j| ds = (@xys[i][0] - @xys[j][0]) ** 2 + (@xys[i][1] - @xys[j][1]) ** 2 graph << [[i, j], ds] end end graph.sort_by! { |g| g[1] } connects = [] graph.each do |p, d| i1 = connects.index { |c| c.include?(p[0]) || c.include?(p[1]) } if i1 connects[i1] += p i2 = connects.drop(i1 + 1).index { |c| c.include?(p[0]) || c.include?(p[1]) } if i2 c = connects.delete_at(i1 + 1 + i2) connects[i1] += c end else connects << p end return d if connects.any? { |connect| connect.include?(0) && connect.include?(@n - 1) } end end def run r = calc (BigDecimal(r).sqrt(Math.log10(r).to_i) / 10).ceil * 10 end end puts Calc0168.new(STDIN.readlines).run if __FILE__ == $0