結果
問題 | No.721 Die tertia (ディエ・テルツィア) |
ユーザー |
![]() |
提出日時 | 2020-08-04 07:41:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 987 bytes |
コンパイル時間 | 612 ms |
コンパイル使用メモリ | 67,024 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 04:43:13 |
合計ジャッジ時間 | 1,309 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <iostream> #include <string> using namespace std; bool leap(int Y){ return Y % 400 == 0 || Y % 100 != 0 && Y % 4 == 0; } void next(int &Y, int &M, int &D){ if (M == 2){ if (leap(Y)){ if (D == 29){ M++; D = 1; } else { D++; } } else { if (D == 28){ M++; D = 1; } else { D++; } } } else if (M == 4 || M == 6 || M == 9 || M == 11){ if (D == 30){ M++; D = 1; } else { D++; } } else if (M == 12){ if (D == 31){ Y++; M = 1; D = 1; } else { D++; } } else { if (D == 31){ M++; D = 1; } else { D++; } } } int main(){ int Y; char s1; int M; char s2; int D; cin >> Y >> s1 >> M >> s2 >> D; next(Y, M, D); next(Y, M, D); string Y2 = to_string(Y); while (Y2.size() < 4){ Y2 = '0' + Y2; } string M2 = to_string(M); while (M2.size() < 2){ M2 = '0' + M2; } string D2 = to_string(D); while (D2.size() < 2){ D2 = '0' + D2; } cout << Y2 << s1 << M2 << s2 << D2 << endl; }