結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー 情報学生情報学生
提出日時 2019-08-20 09:57:25
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 1,347 bytes
コンパイル時間 9,673 ms
コンパイル使用メモリ 170,112 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 01:59:40
合計ジャッジ時間 5,628 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 3 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List.Split
import Text.Printf

is_leap_year :: Int -> Bool
is_leap_year yy
    | yy `mod` 400 == 0 = True
    | yy `mod` 100 == 0 = False
    | yy `mod`   4 == 0 = True
    | otherwise         = False

is28 :: [Int] -> Bool
is28 [yy, mm, dd]
    | (not $ is_leap_year yy) && mm == 2 = True
    | otherwise                          = False

is29 :: [Int] -> Bool
is29 [yy, mm, dd]
    | is_leap_year yy && mm == 2 = True
    | otherwise                  = False

is30 :: [Int] -> Bool
is30 [yy, mm, dd]
    | elem mm [4, 6, 9, 11] = True
    | otherwise             = False

is31 :: [Int] -> Bool
is31 [yy, mm, dd]
    | elem mm [1, 3, 5, 7, 8, 10, 12] = True
    | otherwise                       = False

main :: IO ()
main = getLine >>= solve

solve :: String -> IO ()
solve s = printf "%d/%02d/%02d" yy mm dd
    where
        [y, m, d] = map (read :: String -> Int) $ splitOn "/" s
        [yy, mm, dd] = g [y, m, d]

g :: [Int] -> [Int]
g xs@[y,m,d]
    | d <= 26 = [y, m, d + 2]
    | is28 xs = if is_leap_year y then [y, m, d + 2] else [y, m + 1, (d + 2) `mod` 28]
    | is29 xs = if d == 27 then [y, m , d + 2] else [y, m + 1, (d + 2) `mod` 29]
    | is30 xs = if d <= 28 then [y, m, d + 2] else [y, m + 1, (d + 2) `mod` 30]
    | is31 xs && m == 12 && d >= 30 = [y + 1, 1, (d + 2) `mod` 31]
    | otherwise = [y, m + 1, d + 2]
0