結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー MSKMSK
提出日時 2018-10-03 07:01:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,225 bytes
コンパイル時間 813 ms
コンパイル使用メモリ 72,592 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 14:36:55
合計ジャッジ時間 1,469 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(void) {
  string S;
  cin >> S;
  int year = atoi(S.substr(0, 4).c_str());
  int month = atoi(S.substr(5, 2).c_str());
  int day = atoi(S.substr(8, 2).c_str());
  bool leapyear = false;
  if(((0 == year % 4) && (0 < year % 100))
     || (0 == year % 400)) {
    leapyear = true;
  }
  day += 2;
  if(2 == month && !leapyear && day > 28) {
    month++;
    day -= 28;
  } else if(2 == month && leapyear && day > 29) {
    month++;
    day -= 29;
  } else if(4 == month && day > 30) {
    month++;
    day -= 30;
  } else if(6 == month && day > 30) {
    month++;
    day -= 30;
  } else if(9 == month && day > 30) {
    month++;
    day -= 30;
  } else if(11 == month && day > 30) {
    month++;
    day -= 30;
  } else if(day > 31) {
    month++;
    day -= 31;
    if(13 == month) {
      year++;
      month -= 12;
    }
  }

  ostringstream smonthout;
  smonthout << setfill('0') << setw(2) << month;
  string monthstr = smonthout.str();

  ostringstream sdayout;
  sdayout << setfill('0') << setw(2) << day;
  string daystr = sdayout.str();

  cout << year << '/' << monthstr << '/' << daystr << endl;
  return 0;
}
0