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