結果

問題 No.32 貯金箱の憂鬱
ユーザー regeregeregerege
提出日時 2015-09-05 09:03:16
言語 F#
(F# 4.0)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 523 bytes
コンパイル時間 5,343 ms
コンパイル使用メモリ 160,516 KB
実行使用メモリ 25,124 KB
最終ジャッジ日時 2023-09-30 07:55:24
合計ジャッジ時間 6,474 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
23,072 KB
testcase_01 AC 88 ms
22,952 KB
testcase_02 AC 87 ms
20,984 KB
testcase_03 AC 90 ms
23,252 KB
testcase_04 AC 91 ms
23,008 KB
testcase_05 AC 91 ms
23,120 KB
testcase_06 AC 91 ms
23,088 KB
testcase_07 AC 92 ms
23,136 KB
testcase_08 AC 92 ms
21,196 KB
testcase_09 AC 89 ms
25,124 KB
testcase_10 AC 92 ms
23,196 KB
testcase_11 AC 90 ms
23,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

    let L = int <| stdin.ReadLine()
    let M = int <| stdin.ReadLine()
    let N = int <| stdin.ReadLine()
    let money =
        Seq.zip [100;25;1;] [L;M;N]
        |> Seq.map (fun (a,b) -> a*b)
        |> Seq.reduce ((+))
    let coins = [1000;100;25;1;]
    let rec f l m p =
        let a,b = m/coins.[p],m%coins.[p]
        if m - a*coins.[p] = 0 then l@[a]
        else f (l@[a]) (m-a*coins.[p]) (p+1)
    match f [] money 0 with
    | [] | [_] -> 0
    | l -> l |> Seq.skip 1 |> Seq.reduce((+))
    |> printfn "%d"
0