結果

問題 No.87 Advent Calendar Problem
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-09-09 20:52:20
言語 Haskell
(9.6.2)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 668 bytes
コンパイル時間 8,839 ms
コンパイル使用メモリ 164,904 KB
実行使用メモリ 9,180 KB
最終ジャッジ日時 2023-08-10 07:24:12
合計ジャッジ時間 10,322 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
8,596 KB
testcase_01 AC 3 ms
8,256 KB
testcase_02 AC 4 ms
8,776 KB
testcase_03 AC 2 ms
7,420 KB
testcase_04 AC 3 ms
7,544 KB
testcase_05 AC 4 ms
8,152 KB
testcase_06 AC 4 ms
9,064 KB
testcase_07 AC 3 ms
8,744 KB
testcase_08 AC 4 ms
8,668 KB
testcase_09 AC 4 ms
8,384 KB
testcase_10 AC 4 ms
8,636 KB
testcase_11 AC 2 ms
7,636 KB
testcase_12 AC 3 ms
7,912 KB
testcase_13 AC 3 ms
8,248 KB
testcase_14 AC 4 ms
8,556 KB
testcase_15 AC 4 ms
8,808 KB
testcase_16 AC 5 ms
9,180 KB
testcase_17 AC 5 ms
9,148 KB
testcase_18 AC 4 ms
8,392 KB
testcase_19 AC 4 ms
9,168 KB
testcase_20 AC 4 ms
9,088 KB
testcase_21 AC 4 ms
8,780 KB
testcase_22 AC 2 ms
7,484 KB
testcase_23 AC 3 ms
8,148 KB
testcase_24 AC 3 ms
7,648 KB
testcase_25 AC 4 ms
9,136 KB
testcase_26 AC 5 ms
9,136 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 #

import Data.Int (Int64)
import Data.List (genericLength)
import Data.Time.Calendar (fromGregorian)
import Data.Time.Format (FormatTime, defaultTimeLocale, formatTime)

dayOfWeek :: (FormatTime t) => t -> Int
dayOfWeek = read . formatTime defaultTimeLocale "%w"

naiveCount :: Integral a => a -> a
naiveCount x = genericLength . filter (== d) . fmap year2day $ [2015 .. x]
    where
        year2day y = dayOfWeek $ fromGregorian (fromIntegral y) 7 23
        d = year2day (2014 :: Int)

solve :: Integral a => a -> a
solve x = naiveCount (2015 + m) + 57 * d
    where
        (d, m) = divMod (x - 2015) 400

main :: IO ()
main = print . solve =<< (readLn :: IO Int64)
0