結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-28 18:45:33
言語 Java19
(openjdk 21)
結果
AC  
実行時間 172 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 76,780 KB
実行使用メモリ 57,272 KB
最終ジャッジ日時 2023-07-26 16:56:03
合計ジャッジ時間 7,450 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
57,004 KB
testcase_01 AC 172 ms
56,764 KB
testcase_02 AC 149 ms
57,064 KB
testcase_03 AC 169 ms
56,916 KB
testcase_04 AC 170 ms
56,956 KB
testcase_05 AC 169 ms
56,924 KB
testcase_06 AC 169 ms
57,244 KB
testcase_07 AC 170 ms
56,852 KB
testcase_08 AC 165 ms
57,024 KB
testcase_09 AC 167 ms
57,272 KB
testcase_10 AC 164 ms
56,624 KB
testcase_11 AC 166 ms
56,992 KB
testcase_12 AC 168 ms
56,988 KB
testcase_13 AC 165 ms
56,648 KB
testcase_14 AC 151 ms
56,780 KB
testcase_15 AC 152 ms
56,612 KB
testcase_16 AC 169 ms
57,012 KB
testcase_17 AC 168 ms
56,712 KB
testcase_18 AC 168 ms
57,048 KB
testcase_19 AC 165 ms
56,980 KB
testcase_20 AC 166 ms
56,936 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