ABC081B - Shift only
Mix.install([
{:kino, "~> 0.14"}
])
問題
回答2
2
|> :math.pow(4)
|> round()
|> Kernel.*(5)
|> Integer.to_string(2)
|> String.split("1")
|> Enum.at(-1)
|> String.length()
|> dbg()
defmodule Main do
def main do
:stdio
|> IO.read(:all)
|> solve()
|> IO.puts()
end
defp split_lines(lines) do
lines
|> String.trim()
|> String.split("\n")
end
defp split_words(words) do
String.split(words, " ")
end
def solve(input) do
input
|> split_lines()
|> Enum.at(1)
|> split_words()
|> Enum.map(fn str ->
str
|> String.to_integer()
|> Integer.to_string(2)
|> String.split("1")
|> Enum.at(-1)
|> String.length()
end)
|> Enum.min()
end
end
"""
3
8 12 40
"""
|> Main.solve()
|> then(&(&1 == 2))
"""
4
5 6 8 10
"""
|> Main.solve()
|> then(&(&1 == 0))
"""
6
382253568 723152896 37802240 379425024 404894720 471526144
"""
|> Main.solve()
|> then(&(&1 == 8))