結果

問題 No.500 階乗電卓
ユーザー norioc
提出日時 2024-08-02 02:56:46
言語 Elixir
(1.18.1)
結果
WA  
実行時間 -
コード長 446 bytes
コンパイル時間 2,575 ms
コンパイル使用メモリ 62,176 KB
実行使用メモリ 55,852 KB
最終ジャッジ日時 2024-08-02 02:57:07
合計ジャッジ時間 17,681 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def input, do: IO.read(:line) |> String.trim
  def ii, do: input() |> String.to_integer
  def li, do: input() |> String.split |> Enum.map(&String.to_integer/1)
  def yn(b), do: (if b, do: "Yes", else: "No")

  @mod 10 ** 12
  def main do
    n = ii()
    ans = f(1, n, 1)
    IO.puts ans
  end

  def f(_, _, 0), do: 0
  def f(x, n, t) do
    cond do
      x > n -> t
      true -> f(x+1, n, rem(x*t, @mod))
    end
  end
end
0