結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー SotaSota
提出日時 2024-02-07 21:09:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,627 bytes
コンパイル時間 841 ms
コンパイル使用メモリ 96,988 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-07 21:09:59
合計ジャッジ時間 2,022 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>		//cin, cout
#include <vector>		//vector
#include <algorithm>	//sort,min,max,count
#include <string>		//string,getline, to_string
#include <cstdlib>		//abs(int)
#include <utility>		//swap, pair
#include <deque>		//deque
#include <climits>		//INT_MAX
#include <bitset>		//bitset
#include <cmath>		//sqrt, ceil. M_PI, pow, sin
#include <ios>			//fixed
#include <iomanip>		//setprecision
#include <sstream>		//stringstream
#include <numeric>		//gcd, assumlate
#include <random>		//randam_device
#include <limits>		//numeric_limits

using namespace std;
constexpr int64_t D_MOD = 1000000007;

inline bool JudgeLeapYear(int year) {
    bool flg = false;
    if (year % 4 == 0) {
        flg = true;
        if (year % 100 == 0) {
            flg = false;
            if (year % 400 == 0) {
                flg = true;
            }
        }
    }
    return(flg);
}

int main() {

    string Y, M, D;
    char c;

    for (int i = 0; i < 4; i++) {
        cin >> c;
        Y.push_back(c);
    }
    cin >> c;

    for (int i = 0; i < 2; i++) {
        cin >> c;
        M.push_back(c);
    }
    cin >> c;

    for (int i = 0; i < 2; i++) {
        cin >> c;
        D.push_back(c);
    }

    int yy = stoi(Y), mm = stoi(M), dd = stoi(D);

    bool flg_u = JudgeLeapYear(yy);

    if (dd <= 26) {
        dd += 2;
    }
    else if (dd == 27) {
        if (mm != 2 || flg_u) {
            dd = 29;
        }
        else {
            mm = 3;
            dd = 1;
        }
    }
    else if (dd == 28) {
        if (mm != 2) {
            dd = 30;
        }
        else if (flg_u) {
            mm = 3;
            dd = 1;
        }
        else {
            mm = 3;
            dd = 2;
        }
    }
    else if (dd == 29) {
        if (mm == 2 && flg_u) {
            mm = 3;
            dd = 2;
        }
        else if (mm == 4 || mm == 6 || mm == 9 || mm == 11) {
            mm++;
            dd = 1;
        }
        else {
            dd = 31;
        }
    }
    else if (dd == 30) {
        if (mm == 4 || mm == 6 || mm == 9 || mm == 11) {
            mm++;
            dd = 2;
        }
        else if (mm == 12) {
            yy++;
            mm = 1;
            dd = 1;
        }
        else {
            dd = 1;
        }
    }
    else {
        if (mm == 12) {
            yy++;
            mm = 1;
            dd = 2;
        }
        else {
            dd = 2;
        }
    }

    cout << yy << "/";
    if (mm < 10) {
        cout << 0;
    }
    cout << mm << "/";
    if (dd < 10) {
        cout << 0;
    }
    cout << dd << endl;

    return 0;

}
0