結果
| 問題 |
No.87 Advent Calendar Problem
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-09-09 20:54:38 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 690 bytes |
| コンパイル時間 | 255 ms |
| コンパイル使用メモリ | 154,368 KB |
| 最終ジャッジ日時 | 2024-11-14 19:48:56 |
| 合計ジャッジ時間 | 645 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:3:1: error: [GHC-87110]
Could not load module ‘Data.Time.Calendar’.
It is a member of the hidden package ‘time-1.12.2’.
Use -v to see a list of the files searched for.
|
3 | import Data.Time.Calendar (fromGregorian)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Main.hs:4:1: error: [GHC-87110]
Could not load module ‘Data.Time.Format’.
It is a member of the hidden package ‘time-1.12.2’.
Use -v to see a list of the files searched for.
|
4 | import Data.Time.Format (FormatTime, formatTime)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Main.hs:5:1: error: [GHC-87110]
Could not find module ‘System.Locale’.
Use -v to see a list of the files searched for.
|
5 | import System.Locale (defaultTimeLocale)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Data.Int (Int64)
import Data.List (genericLength)
import Data.Time.Calendar (fromGregorian)
import Data.Time.Format (FormatTime, formatTime)
import System.Locale (defaultTimeLocale)
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)
はむ吉🐹