結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー tactac
提出日時 2019-07-20 13:41:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,539 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 71,816 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 15:05:35
合計ジャッジ時間 1,686 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<iomanip>

using namespace std;

int uruu(int y) {
    if (y % 4 == 0) {
        if (y % 100 == 0) {
            if (y % 400 == 0) {
                return 1;
            }
            return 0;
        }
        return 1;
    }
    return 0;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    string tmp;
    cin >> tmp;
    int m, d, y;
    d = stoi(tmp.substr(8, 2));
    m = stoi(tmp.substr(5, 2));
    if (d <= 26 || (d <= 27 && m != 2)) {
        cout << tmp.substr(0, 8);
        cout << setw(2) << setfill('0') << d + 2 << endl;
    }
    y = stoi(tmp.substr(0, 4));
    if (m != 12) {
        int nd = (d + 2) % (m == 2 && uruu(y) == 1 ? 29 + 1 : days[m - 1] + 1);
        if (nd > d) {
            cout << tmp.substr(0, 8);
            cout << setw(2) << setfill('0') << d + 2 << endl;
        } else { //月が変わる
            nd++;
            cout << tmp.substr(0, 5);
            cout << setw(2) << setfill('0') << m + 1;
            cout << "/";
            cout << setw(2) << setfill('0') << nd << endl;
        }
    } else {
        int nd = (d + 2) % (days[m - 1] + 1);
        if (nd > d) {
            cout << tmp.substr(0, 8);
            cout << setw(2) << setfill('0') << d + 2 << endl;
        } else { //年が変わる
            nd++;
            cout << setw(4) << setfill('0') << y + 1;
            cout << "/01/";
            cout << setw(2) << setfill('0') << nd << endl;
        }
    }
}
0