結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー kappybarkappybar
提出日時 2020-05-03 14:00:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,617 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 167,448 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-02 16:58:16
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int trans(string s){
    int n = s.size();
    int t = 1;
    int res = 0;
    for(int i=n-1;i>=0;i--){
        res += (s[i] - '0') * t;
        t *= 10;
    }
    return res;
}

int main(){
    string s;
    cin >> s;
    string y = s.substr(0,4);
    string m = s.substr(5,2);
    string d = s.substr(8,2);
    int Y = trans(y);
    int M = trans(m);
    int D = trans(d);
    if(Y%400 ==0 && M == 2 && D >= 27){
        if(D == 27) D += 2;
        else if(D == 28) D = 1,M ++;
        else if(D == 29) D = 2,M ++;
    }else if((Y%4 ==0 && Y%100 != 0)&& M == 2 && D >= 27){
        if(D == 27) D += 2;
        else if(D == 28) D = 1,M ++;
        else if(D == 29) D = 2,M ++;
    }else if((M == 4 || M == 6 || M == 9 || M ==11) && D >= 29){
        D = (D + 2)%30;
        M++;
    }else if((M == 1 || M == 3 || M == 5 || M == 7 || M == 8 || M ==10|| M ==12) && D >= 30){
        D = (D + 2)%31;
        M ++;
        if(M ==13){
            M = 1;
            Y ++;
        }
    }else if(M ==2 && D >= 27){
        D = (D + 2)%28;
        M ++;
    }else{
        D += 2;
    }
    if(M <= 9 && D <= 9) cout << Y << "/0" << M << "/0" << D << endl;
    else if(M <= 9) cout << Y << "/0" << M << "/" << D << endl;
    else if(D <= 9) cout << Y << "/" << M << "/0" << D << endl;
    else cout << Y << "/" << M << "/" << D << endl;
    return 0;
}
0