結果
問題 | No.721 Die tertia (ディエ・テルツィア) |
ユーザー |
![]() |
提出日時 | 2019-07-20 13:42:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,557 bytes |
コンパイル時間 | 787 ms |
コンパイル使用メモリ | 71,764 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-29 17:27:55 |
合計ジャッジ時間 | 1,619 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#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; return 0; } 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; } } }