結果

問題 No.500 階乗電卓
ユーザー gemmarogemmaro
提出日時 2020-05-13 08:55:27
言語 Elixir
(1.16.2)
結果
WA  
実行時間 -
コード長 397 bytes
コンパイル時間 1,284 ms
コンパイル使用メモリ 54,216 KB
実行使用メモリ 50,488 KB
最終ジャッジ日時 2023-08-30 00:47:37
合計ジャッジ時間 15,800 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 550 ms
50,196 KB
testcase_01 AC 551 ms
49,448 KB
testcase_02 AC 553 ms
49,404 KB
testcase_03 AC 556 ms
49,968 KB
testcase_04 AC 561 ms
49,264 KB
testcase_05 AC 565 ms
49,368 KB
testcase_06 AC 572 ms
49,820 KB
testcase_07 AC 567 ms
49,428 KB
testcase_08 AC 563 ms
49,904 KB
testcase_09 AC 569 ms
50,008 KB
testcase_10 AC 564 ms
49,640 KB
testcase_11 AC 560 ms
49,416 KB
testcase_12 AC 560 ms
50,140 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 562 ms
49,188 KB
testcase_17 AC 562 ms
49,868 KB
testcase_18 AC 557 ms
49,400 KB
testcase_19 AC 556 ms
49,900 KB
testcase_20 AC 552 ms
49,904 KB
testcase_21 AC 546 ms
49,140 KB
testcase_22 AC 556 ms
49,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  @mask 1_000_000_000_000

  def main do
    IO.read(:line) |> String.trim() |> String.to_integer() |> solve |> IO.puts()
  end

  def solve(n) do
    cond do
      n < 40 -> solve_rec(n, 1)
      true -> "000000000000"
    end
  end

  def solve_rec(1, r) do
    r
  end

  def solve_rec(n, r) do
    tmp = n * r
    solve_rec(n - 1, tmp - (tmp |> div(@mask)) * @mask)
  end
end
0