結果
| 問題 |
No.721 Die tertia (ディエ・テルツィア)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-10-10 21:19:22 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 869 bytes |
| コンパイル時間 | 433 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-10-12 17:21:30 |
| 合計ジャッジ時間 | 3,815 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
コンパイルメッセージ
Syntax OK
ソースコード
inputs = gets.split('/')
y = inputs[0].to_i # year
m = inputs[1].to_i # month
d = inputs[2].to_i # date
def last_date_of(year, month)
thirty_days_month = [4, 6, 9, 11]
thirtyone_days_month = [1, 3, 5, 7, 8, 10, 12]
if thirty_days_month.include?(month)
30
elsif thirtyone_days_month.include?(month)
31
elsif year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)
29
else
28
end
end
after = 2 # 何日後の日付を答えとするか
last_date = last_date_of(y, m)
is_overflow = d + after > last_date
if is_overflow
if m == 12
# 12月で月が変わる場合
ans_y = y + 1
ans_m = 1
else
ans_y = y
ans_m = m + 1
end
ans_d = d + after - last_date
else
ans_y = y
ans_m = m
ans_d = d + after
end
answer = "#{ans_y.to_s.rjust(4, '0')}/#{ans_m.to_s.rjust(2, '0')}/#{ans_d.to_s.rjust(2, '0')}"
puts answer