def lscan;gets.split.map(&:to_i);end # 1Gの商品を 1G 10x+1枚 => コスト1で10x+1-x = 9x+1減らす @a, @b, @c = lscan # 減らしたい枚数 r = @a+@b-@c if @a + @b < @c puts "Impossible" # 10Gを1Gで支払えば増やせるのでWA exit elsif @a + @b == @c if @b == 0 puts "Impossible" else p 9 end exit else cost = 1 x = ([r, @a].min - 1) / 9 @a -= 9*x+1 r -= 9*x+1 a = [r, @a].min cost += a r -= a p cost + (r)*10 end