結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー 3qvwn
提出日時 2019-07-02 10:49:49
言語 Elixir
(1.18.1)
結果
AC  
実行時間 585 ms / 5,000 ms
コード長 409 bytes
コンパイル時間 1,008 ms
コンパイル使用メモリ 64,936 KB
実行使用メモリ 55,452 KB
最終ジャッジ日時 2024-12-31 03:08:45
合計ジャッジ時間 15,975 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    n = IO.gets("") |> String.trim |> String.to_integer
    strike(1, n, 0)
  end
  
  def strike(n, n, count) do
    IO.puts count
  end
  
  def strike(biscuit, n, count) do
    if biscuit * 2 <= n do
      strike(pocket(biscuit), n , count + 1)
    else
      strike(2*biscuit - n + pocket(n - biscuit), n, count + 1)
    end
  end
  
  def pocket(n) do
    n * 2
  end
end
0