結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-28 18:45:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 2,413 ms
コンパイル使用メモリ 80,448 KB
実行使用メモリ 55,332 KB
最終ジャッジ日時 2024-04-14 06:32:09
合計ジャッジ時間 6,870 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
54,860 KB
testcase_01 AC 171 ms
55,116 KB
testcase_02 AC 153 ms
54,996 KB
testcase_03 AC 169 ms
55,156 KB
testcase_04 AC 169 ms
54,992 KB
testcase_05 AC 169 ms
55,012 KB
testcase_06 AC 168 ms
55,020 KB
testcase_07 AC 169 ms
54,864 KB
testcase_08 AC 155 ms
54,984 KB
testcase_09 AC 170 ms
55,028 KB
testcase_10 AC 166 ms
54,972 KB
testcase_11 AC 167 ms
55,188 KB
testcase_12 AC 152 ms
54,696 KB
testcase_13 AC 169 ms
55,288 KB
testcase_14 AC 150 ms
55,024 KB
testcase_15 AC 151 ms
54,876 KB
testcase_16 AC 169 ms
54,988 KB
testcase_17 AC 173 ms
55,332 KB
testcase_18 AC 171 ms
55,220 KB
testcase_19 AC 170 ms
55,204 KB
testcase_20 AC 167 ms
55,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] sp = s.split("/", 0);
    int[] days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    int y = Integer.parseInt(sp[0]);
    int m = Integer.parseInt(sp[1]);
    int d = Integer.parseInt(sp[2]);
    if((y % 4 == 0) && !((y % 100 == 0) && (y % 400 != 0))) days[2] = 29;
    String ans = "";
    if((d + 2) <= days[m]) {
      String sm = String.valueOf(m);
      String sd = String.valueOf(d + 2);
      if(m < 10) sm = "0" + sm;
      if(d < 8) sd = "0" + sd;
      ans = y + "/" + sm + "/" + sd;
    } else {
      int rd = d + 2 - days[m];
      if(m < 12) {
        String sm = String.valueOf(m + 1);
        if(m < 9) sm = "0" + sm;
        ans = y + "/" + sm + "/" + "0" + rd;
      } else {
        ans = (y + 1) + "/01/" + "0" + rd;  
      }
    }
    System.out.println(ans);
  }
}
0