結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー 3qvwn3qvwn
提出日時 2019-07-02 10:49:49
言語 Elixir
(1.16.2)
結果
AC  
実行時間 644 ms / 5,000 ms
コード長 409 bytes
コンパイル時間 1,145 ms
コンパイル使用メモリ 54,968 KB
実行使用メモリ 49,936 KB
最終ジャッジ日時 2023-08-29 23:32:02
合計ジャッジ時間 18,034 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 629 ms
49,136 KB
testcase_01 AC 630 ms
49,328 KB
testcase_02 AC 626 ms
49,844 KB
testcase_03 AC 626 ms
49,328 KB
testcase_04 AC 609 ms
49,136 KB
testcase_05 AC 634 ms
49,760 KB
testcase_06 AC 630 ms
49,752 KB
testcase_07 AC 626 ms
49,888 KB
testcase_08 AC 624 ms
49,672 KB
testcase_09 AC 628 ms
49,280 KB
testcase_10 AC 623 ms
49,884 KB
testcase_11 AC 633 ms
49,328 KB
testcase_12 AC 622 ms
49,088 KB
testcase_13 AC 624 ms
49,196 KB
testcase_14 AC 628 ms
49,164 KB
testcase_15 AC 625 ms
49,104 KB
testcase_16 AC 630 ms
49,744 KB
testcase_17 AC 634 ms
49,936 KB
testcase_18 AC 635 ms
49,208 KB
testcase_19 AC 644 ms
49,368 KB
testcase_20 AC 631 ms
49,220 KB
testcase_21 AC 623 ms
49,272 KB
testcase_22 AC 613 ms
49,104 KB
testcase_23 AC 628 ms
49,388 KB
権限があれば一括ダウンロードができます

ソースコード

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