結果
問題 | No.721 Die tertia (ディエ・テルツィア) |
ユーザー |
|
提出日時 | 2018-10-03 07:01:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,225 bytes |
コンパイル時間 | 605 ms |
コンパイル使用メモリ | 71,528 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 10:11:52 |
合計ジャッジ時間 | 1,447 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <iomanip> #include <iostream> #include <sstream> #include <string> using namespace std; int main(void) { string S; cin >> S; int year = atoi(S.substr(0, 4).c_str()); int month = atoi(S.substr(5, 2).c_str()); int day = atoi(S.substr(8, 2).c_str()); bool leapyear = false; if(((0 == year % 4) && (0 < year % 100)) || (0 == year % 400)) { leapyear = true; } day += 2; if(2 == month && !leapyear && day > 28) { month++; day -= 28; } else if(2 == month && leapyear && day > 29) { month++; day -= 29; } else if(4 == month && day > 30) { month++; day -= 30; } else if(6 == month && day > 30) { month++; day -= 30; } else if(9 == month && day > 30) { month++; day -= 30; } else if(11 == month && day > 30) { month++; day -= 30; } else if(day > 31) { month++; day -= 31; if(13 == month) { year++; month -= 12; } } ostringstream smonthout; smonthout << setfill('0') << setw(2) << month; string monthstr = smonthout.str(); ostringstream sdayout; sdayout << setfill('0') << setw(2) << day; string daystr = sdayout.str(); cout << year << '/' << monthstr << '/' << daystr << endl; return 0; }