結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2024-08-02 03:39:57 |
| 言語 | Elixir (1.18.1) |
| 結果 |
AC
|
| 実行時間 | 567 ms / 2,000 ms |
| コード長 | 562 bytes |
| コンパイル時間 | 1,039 ms |
| コンパイル使用メモリ | 62,704 KB |
| 実行使用メモリ | 55,820 KB |
| 最終ジャッジ日時 | 2024-08-02 03:40:15 |
| 合計ジャッジ時間 | 15,731 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
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()
x = f(1, n, 1)
ans = case x do
0 -> String.duplicate("0", 12)
_ -> Integer.to_string(x) |> String.slice(-12..-1)
end
IO.puts ans
end
def f(x, n, t) do
cond do
rem(t, @mod) == 0 -> 0
x > n -> t
true -> f(x+1, n, x*t)
end
end
end
norioc