結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー yoneoka1985yoneoka1985
提出日時 2018-10-10 21:58:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,408 bytes
コンパイル時間 3,373 ms
コンパイル使用メモリ 80,040 KB
実行使用メモリ 41,436 KB
最終ジャッジ日時 2024-04-20 19:30:44
合計ジャッジ時間 6,434 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class DieTeria {

	static Map<Integer, Integer> lastDay = new HashMap<Integer, Integer>() {
		{
			put(1, 31);
			put(2, 28);
			put(3, 31);
			put(4, 30);
			put(5, 31);
			put(6, 30);
			put(7, 31);
			put(8, 31);
			put(9, 30);
			put(10, 31);
			put(11, 30);
			put(12, 31);
		}
	};

	static int n = 2;

	public static void main(String[] args) {
		// 標準入力から読み込む際に、Scannerオブジェクトを使う。
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int year = Integer.parseInt(s.split("/")[0]);
		int month = Integer.parseInt(s.split("/")[1]);
		int day = Integer.parseInt(s.split("/")[2]);

		if (isUruu(year)) {
			lastDay.put(2, 29);
		}

		day += n;

		if (isOver(month, day)) {
			month++;
			while (isOver(month, day)) {
				day--;
			}
		}
		if(month == 13) {
			month =12;
			year++;
		}
		
		

		System.out.println(String.format("%04d/%02d/%02d", year, month, day));

	}
	
	static boolean isUruu(int year) {

		if (year / 400 == 0) {
			return false;
		} else if (year / 4 == 0) {
			return true;
		}

		return false;
	}

	static boolean isLastDay(int month, int day) {
		return (day == lastDay.get(month));
	}

	static boolean isOver(int month, int day) {
		return (day > lastDay.get(month));
	}

	static boolean isLastMonth(int month) {
		return (month == 12);
	}

}
0