結果
| 問題 |
No.721 Die tertia (ディエ・テルツィア)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-18 11:03:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,470 bytes |
| コンパイル時間 | 1,546 ms |
| コンパイル使用メモリ | 172,648 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 21:36:55 |
| 合計ジャッジ時間 | 2,178 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
bool IsLeapYear(int year);
int main() {
string s;
cin >> s;
string tmp = "";
vector<string> v;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '/') {
v.push_back(tmp);
tmp = "";
} else {
tmp += s[i];
}
}
v.push_back(tmp);
int year = stoi(v[0]);
int month = stoi(v[1]);
int day = stoi(v[2]) + 2;
if (month == 2) {
if (IsLeapYear(year)) {
if (day > 29) {
month++;
day -= 29;
}
} else {
if (day > 28) {
month++;
day -= 28;
}
}
} else if ((month == 4 || month == 6 || month == 9 || month == 11) &&
day > 30) {
month++;
day -= 30;
} else if (day > 31) {
if (month == 12) {
year++;
}
month = (month + 1) % 12;
day -= 31;
}
cout << year << "/";
cout << setfill('0') << std::right << setw(2) << month << "/" ;
cout << setfill('0') << std::right << setw(2) << day << endl;
return 0;
}
bool IsLeapYear (int year) {
bool ret = false;
if (year % 4 == 0) {
if (year % 100 == 0) {
if (year % 400 == 0) {
ret = true;
}
} else {
ret = true;
}
}
return ret;
}