結果
問題 | No.721 Die tertia (ディエ・テルツィア) |
ユーザー | gemmaro |
提出日時 | 2020-04-16 10:36:21 |
言語 | Elixir (1.16.2) |
結果 |
AC
|
実行時間 | 652 ms / 2,000 ms |
コード長 | 1,546 bytes |
コンパイル時間 | 1,080 ms |
コンパイル使用メモリ | 55,928 KB |
実行使用メモリ | 50,092 KB |
最終ジャッジ日時 | 2023-08-30 00:15:20 |
合計ジャッジ時間 | 18,076 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 629 ms
49,128 KB |
testcase_01 | AC | 630 ms
49,828 KB |
testcase_02 | AC | 622 ms
49,200 KB |
testcase_03 | AC | 621 ms
49,264 KB |
testcase_04 | AC | 622 ms
50,092 KB |
testcase_05 | AC | 622 ms
49,356 KB |
testcase_06 | AC | 637 ms
49,096 KB |
testcase_07 | AC | 626 ms
49,880 KB |
testcase_08 | AC | 652 ms
49,056 KB |
testcase_09 | AC | 646 ms
47,760 KB |
testcase_10 | AC | 647 ms
48,664 KB |
testcase_11 | AC | 649 ms
49,204 KB |
testcase_12 | AC | 637 ms
49,124 KB |
testcase_13 | AC | 636 ms
47,684 KB |
testcase_14 | AC | 648 ms
48,932 KB |
testcase_15 | AC | 643 ms
49,816 KB |
testcase_16 | AC | 648 ms
49,264 KB |
testcase_17 | AC | 632 ms
49,352 KB |
testcase_18 | AC | 632 ms
50,012 KB |
testcase_19 | AC | 645 ms
49,328 KB |
testcase_20 | AC | 648 ms
49,860 KB |
ソースコード
defmodule Main do def main do IO.read(:line) |> String.trim() |> String.split("/") |> Enum.map(&String.to_integer/1) |> solve |> IO.puts() end defp solve([year, month, day]) do [year, month, day + 2] |> fix_day_and_month |> fix_month_and_year |> format_result end defp fix_day_and_month([year, month, day]) when month == 2 do cond do uruh?(year) && day > 29 -> [year, month + 1, day - 29] !uruh?(year) && day > months(month - 1) -> [year, month + 1, day - months(month - 1)] true -> [year, month, day] end end defp fix_day_and_month([year, month, day]) do cond do day > months(month - 1) -> [year, month + 1, day - months(month - 1)] true -> [year, month, day] end end defp fix_month_and_year([year, month, day]) do cond do month > 12 -> [year + 1, month - 12, day] true -> [year, month, day] end end defp uruh?(year) do rem(year, 4) == 0 && (!(year |> rem(100) == 0) || year |> rem(400) == 0) end defp months(month) do [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] |> Enum.at(month) end defp format_result([year, month, day]) do [year, month, day] |> Enum.map(&to_string/1) |> (fn [year, month, day] -> [ year |> String.pad_leading(4, "0"), month |> String.pad_leading(2, "0"), day |> String.pad_leading(2, "0") ] end).() |> Enum.join("/") end end