Submission #38365766
Source Code Expand
defmodule Main do
def main do
IO.read(:line)
IO.read(:line)
|> String.trim()
|> String.split(" ")
|> Enum.map(&String.to_integer/1)
|> Enum.reduce_while(10_000_000_000, fn a, acc ->
a
|> do_solve(0)
|> calc_new_acc(acc)
|> calc_result()
end)
|> IO.puts()
end
defp do_solve(a, acc) when rem(a, 2) == 1, do: acc
defp do_solve(a, acc), do: do_solve(div(a, 2), acc + 1)
defp calc_new_acc(cnt, acc) when cnt < acc, do: cnt
defp calc_new_acc(cnt, acc), do: acc
defp calc_result(0), do: {:halt, 0}
defp calc_result(acc), do: {:cont, acc}
end
Submission Info
| Submission Time | |
|---|---|
| Task | B - Shift only |
| User | awesomey |
| Language | Elixir (1.10.2) |
| Score | 200 |
| Code Size | 641 Byte |
| Status | AC |
| Exec Time | 339 ms |
| Memory | 30796 KiB |
Compile Error
warning: variable "cnt" is unused (if the variable is not meant to be used, prefix it with an underscore) Main.ex:24: Main.calc_new_acc/2
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample1.txt, sample2.txt, sample3.txt |
| All | sample1.txt, sample2.txt, sample3.txt, 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, sample1.txt, sample2.txt, sample3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 1.txt | AC | 339 ms | 30292 KiB |
| 2.txt | AC | 336 ms | 30396 KiB |
| 3.txt | AC | 323 ms | 30728 KiB |
| 4.txt | AC | 329 ms | 30592 KiB |
| 5.txt | AC | 336 ms | 30272 KiB |
| 6.txt | AC | 335 ms | 30640 KiB |
| 7.txt | AC | 334 ms | 30500 KiB |
| sample1.txt | AC | 326 ms | 30672 KiB |
| sample2.txt | AC | 328 ms | 30796 KiB |
| sample3.txt | AC | 325 ms | 30568 KiB |