結果

問題 No.639 An Ordinary Sequence
ユーザー taktak
提出日時 2018-04-20 15:21:02
言語 F#
(.NET 7)
結果
AC  
実行時間 90 ms / 1,000 ms
コード長 525 bytes
コンパイル時間 5,481 ms
コンパイル使用メモリ 164,768 KB
実行使用メモリ 25,116 KB
最終ジャッジ日時 2023-08-30 12:59:51
合計ジャッジ時間 8,197 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
25,052 KB
testcase_01 AC 88 ms
20,976 KB
testcase_02 AC 88 ms
23,068 KB
testcase_03 AC 87 ms
22,972 KB
testcase_04 AC 87 ms
22,980 KB
testcase_05 AC 87 ms
23,040 KB
testcase_06 AC 87 ms
23,064 KB
testcase_07 AC 87 ms
22,984 KB
testcase_08 AC 89 ms
25,116 KB
testcase_09 AC 87 ms
22,988 KB
testcase_10 AC 88 ms
23,084 KB
testcase_11 AC 89 ms
25,096 KB
testcase_12 AC 89 ms
25,100 KB
testcase_13 AC 88 ms
22,988 KB
testcase_14 AC 90 ms
23,040 KB
testcase_15 AC 86 ms
23,004 KB
testcase_16 AC 87 ms
23,080 KB
testcase_17 AC 89 ms
23,188 KB
testcase_18 AC 88 ms
22,960 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

/home/judge/data/code/Main.fs(16,13): warning FS0040: This and other recursive references to the object(s) being defined will be checked for initialization-soundness at runtime through the use of a delayed reference. This is because you are defining one or more recursive objects, rather than recursive functions. This warning may be suppressed by using '#nowarn "40"' or '--nowarn:40'.

ソースコード

diff #

let memo f = 
    let dict = new System.Collections.Generic.Dictionary<_,_>()
    let memFunc input =
        match dict.TryGetValue input with
        | true,x -> x
        | false,_ ->
            let ans = f input
            dict.Add(input,ans)
            ans
    memFunc            
        
let rec memF =
    let f = function
       | 0L -> 1L
       | x ->
            memF (x/3L) + memF (x/5L)
    memo f                                    

let N = stdin.ReadLine() |> int64 
               
memF N |> printfn "%i"
0