結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー kat0rikkat0rik
提出日時 2019-08-12 18:49:47
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 14,193 ms
コンパイル使用メモリ 222,720 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 07:47:58
合計ジャッジ時間 14,993 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"strconv"
)

//                     1,   2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12
var days = [13]int{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}

func main() {
	var s string
	fmt.Scan(&s)
	y, _ := strconv.Atoi(s[0:4])
	m, _ := strconv.Atoi(s[5:7])
	d, _ := strconv.Atoi(s[8:10])
	if y%4 == 0 && (y%100 != 0 || y%400 == 0) {
		// leap year
		days[2] = 29
	}
	// fmt.Println("y", y, "m", m, "d", d, "days", days)
	if d+2 > days[m] {
		if d == days[m] {
			d = 2
		} else {
			d = 1
		}
		if m == 12 {
			m = 1
			y++
		} else {
			m++
		}
	} else {
		d += 2
	}

	fmt.Printf("%04d/%02d/%02d\n", y, m, d)
}
0