結果

問題 No.500 階乗電卓
ユーザー hum_op
提出日時 2017-04-17 14:17:49
言語 F#
(F# 4.0)
結果
TLE  
実行時間 -
コード長 571 bytes
コンパイル時間 6,641 ms
コンパイル使用メモリ 186,756 KB
実行使用メモリ 74,236 KB
最終ジャッジ日時 2024-07-19 05:23:53
合計ジャッジ時間 12,578 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (229 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

open System


let No500 () =
    let N = Numerics.BigInteger.Parse <| Console.ReadLine()

    let rec fac (n : Numerics.BigInteger) (f : Numerics.BigInteger) =
        if n = (Numerics.BigInteger.Parse "1") then
            f
        else 
            fac (n - (Numerics.BigInteger.Parse "1")) (f * n)

    let ans = (fac N (Numerics.BigInteger.Parse "1") ).ToString()
    if ans.Length > 12 then
        for i = ans.Length - 12 to ans.Length - 1 do
            printf "%c" ans.[i]
            done
        printfn ""
    else 
        printfn "%s" ans

    ()


No500 ()
0