結果

問題 No.32 貯金箱の憂鬱
ユーザー momen999momen999
提出日時 2017-04-12 13:27:39
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 900 bytes
コンパイル時間 2,640 ms
コンパイル使用メモリ 165,304 KB
実行使用メモリ 7,176 KB
最終ジャッジ日時 2023-09-30 10:13:30
合計ジャッジ時間 3,598 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,052 KB
testcase_01 AC 2 ms
6,924 KB
testcase_02 AC 2 ms
6,988 KB
testcase_03 AC 3 ms
7,000 KB
testcase_04 AC 3 ms
7,080 KB
testcase_05 AC 3 ms
7,176 KB
testcase_06 AC 2 ms
7,000 KB
testcase_07 AC 2 ms
7,060 KB
testcase_08 AC 3 ms
7,100 KB
testcase_09 AC 2 ms
7,120 KB
testcase_10 AC 3 ms
7,060 KB
testcase_11 AC 3 ms
7,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

ryougae :: Int -> Int -> Int -> Int
ryougae en100 en25 en1 =
    let
        cntup1 = cnt1To25 en1 0
        en1' = en1 - cntup1 * 25
        cntup25 = cnt25To100 (en25 + cntup1) 0
        en25' = (en25 + cntup1) - cntup25 * 4
        cntup100 = cnt100To1000 (en100 + cntup25) 0
        en100' = (en100 + cntup25) - cntup100 * 10
    in
        en100' + en25' + en1'
    where
        cnt1To25 en i   | en < 25   = i
                        | otherwise = cnt1To25 (en - 25) (i + 1)
        cnt25To100 en i | en < 4    = i
                        | otherwise = cnt25To100 (en - 4) (i + 1)
        cnt100To1000 en i   | en < 10   = i
                            | otherwise = cnt100To1000 (en - 10) (i + 1)

main = do
    str1 <- getLine
    str2 <- getLine
    str3 <- getLine
    let
        en_100 = read str1
        en_25 = read str2
        en_1 = read str3
    print $ ryougae en_100 en_25 en_1
0