結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-02-19 17:32:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 1,380 ms
コンパイル使用メモリ 158,308 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 14:42:43
合計ジャッジ時間 2,277 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:32:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |     scanf("%d/%d/%d",&y,&m,&d);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void daypls(int& y,int& m,int& d) {
    d+=2;
    if ((m<=7&&m%2==1)||(m>=8&&m%2==0)) {//31days
        m+=d>31?1:0;
        d--;d%=31;d++;
        y+=m>12?1:0;
        m%=12;
    } else if (m!=2) {
        m+=d>30?1:0;
        d--;d%=30;d++;
    } else {
        if (y%400==0||(y%100!=0&&y%4==0)) {
            m+=d>29?1:0;
            d--;d%=29;d++;
        } else {
            m+=d>28?1:0;
            d--;d%=28;d++;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int y,m,d;
    scanf("%d/%d/%d",&y,&m,&d);
    daypls(y,m,d);
    cout <<y<<'/';
    if (m/10<1) cout << 0;
    cout << m << '/';
    if (d/10<1) cout << 0;
    cout << d << endl;
    return 0;
}
0