結果

問題 No.87 Advent Calendar Problem
コンテスト
ユーザー kou_kkk
提出日時 2025-07-28 07:45:04
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 967µs
コード長 629 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,696 ms
コンパイル使用メモリ 197,760 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-07-13 14:58:11
合計ジャッジ時間 11,641 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

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
0