結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー kkkk97368086kkkk97368086
提出日時 2021-11-28 10:19:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 1,945 ms
コンパイル使用メモリ 186,444 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 17:48:00
合計ジャッジ時間 3,082 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  string S; cin >> S;
  int Y = stoi(S.substr(0,4));
  int M = stoi(S.substr(5,7));
  int D = stoi(S.substr(8,10));
  switch(M){
    case 1:
    case 3:
    case 5:
    case 7:
    case 8:
    case 10:
    case 12:
      if(30 <= D){
        if(M == 12){
          Y++;
          M = 0;
        }
        M++;
        D -= 29;
      }else{ 
        D += 2;
      }
      break;
    case 4:
    case 6:
    case 9:
    case 11:
      if(29 <= D){
        M++;
        D -= 28;
      }else{
        D += 2;
      }
      break;
    case 2:
      if(Y%400 == 0 or (Y%100 != 0 and Y%4 == 0)){
        if(28 <= D){
          M++;
          D -= 27;
        }else{
          D += 2;
        }
        break;
      }else{
        if(27 <= D){
          M++;
          D -= 26;
        }else{
          D += 2;
        }
      }
  }
  printf("%2d/%02d/%02d\n", Y, M, D);
}
0