結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー gemmarogemmaro
提出日時 2019-10-23 12:09:30
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 683 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 11,420 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2023-09-20 09:27:56
合計ジャッジ時間 2,756 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,248 KB
testcase_01 AC 82 ms
15,052 KB
testcase_02 AC 84 ms
15,292 KB
testcase_03 AC 81 ms
15,088 KB
testcase_04 AC 82 ms
15,164 KB
testcase_05 AC 81 ms
15,164 KB
testcase_06 AC 81 ms
15,292 KB
testcase_07 AC 82 ms
15,356 KB
testcase_08 AC 81 ms
15,040 KB
testcase_09 AC 81 ms
15,300 KB
testcase_10 AC 81 ms
15,168 KB
testcase_11 AC 80 ms
15,136 KB
testcase_12 AC 79 ms
15,252 KB
testcase_13 AC 80 ms
15,140 KB
testcase_14 AC 80 ms
15,356 KB
testcase_15 AC 82 ms
15,328 KB
testcase_16 AC 81 ms
15,176 KB
testcase_17 AC 81 ms
15,140 KB
testcase_18 AC 80 ms
15,148 KB
testcase_19 AC 80 ms
15,264 KB
testcase_20 AC 82 ms
15,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$months = [
  31, 28, 31, 30,
  31, 30, 31, 31,
  30, 31, 30, 31
]

year, month, day = gets.chomp.split('/').map &:to_i
day += 2

# @param int year
# @return bool
def uruh?(year)
  if year % 4 == 0
    if year % 100 == 0 and year % 400 != 0
      return false
    end
    return true
  end
  return false
end

if month == 2
  if uruh?(year)
    if day > 29
      day -= 29
      month += 1
    end
  else
    if day > $months[month - 1]
      day -= $months[month - 1]
      month += 1
    end
  end
else
  if day > $months[month - 1]
    day -= $months[month - 1]
    month += 1
  end
end

if month > 12
  year += 1
  month -= 12
end

puts format("%04d/%02d/%02d", year, month, day)
0