結果
問題 |
No.87 Advent Calendar Problem
|
ユーザー |
![]() |
提出日時 | 2025-07-28 07:45:04 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 629 bytes |
コンパイル時間 | 10,203 ms |
コンパイル使用メモリ | 182,144 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-28 07:45:17 |
合計ジャッジ時間 | 11,963 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.10.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
module Main where main :: IO () main = readLn >>= print . solve solve :: Integer -> Integer solve n = loop [1..400] 0 0 * a + loop [1..b] 0 0 where (a, b) = (n-2014) `divMod` 400 loop :: [Integer] -> Integer -> Integer -> Integer loop [] _ ans = ans loop (x:xs) w ans = loop xs w' ans' where w' = (w + d (2014+x)) `mod` 7 ans' | w' == 0 = ans + 1 | otherwise = ans isLeap :: Integer -> Bool isLeap y | y `mod` 400 == 0 = True | y `mod` 100 == 0 = False | y `mod` 4 == 0 = True | otherwise = False d :: Integer -> Integer d y | isLeap y = 366 | otherwise = 365