結果
| 問題 |
No.721 Die tertia (ディエ・テルツィア)
|
| コンテスト | |
| ユーザー |
dgd1724
|
| 提出日時 | 2018-11-24 20:09:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,793 bytes |
| コンパイル時間 | 610 ms |
| コンパイル使用メモリ | 65,804 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 19:24:09 |
| 合計ジャッジ時間 | 1,401 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <fstream>
#include <iostream>
#include <string>
#include <iomanip>
inline bool Judge_LeapYear(int year) {
bool flg = false;
if (year % 4 == 0) {
flg = true;
if (year % 100 == 0) {
flg = false;
if (year % 400 == 0) {
flg = true;
}
}
}
return(flg);
}
inline bool Judge_ThirtyFirst(int month) {
if (month == 2 || month == 4 || month == 6 || month == 9 || month == 11) {
return(false);
}
return(true);
}
int main() {
//std::ifstream inf("Text.txt"); std::cin.rdbuf(inf.rdbuf());
std::string S;
std::cin >> S;
int year = 0, month = 0, day = 0;
year = std::stoi(S.substr(0, 4));
month = std::stoi(S.substr(5, 2));
day = std::stoi(S.substr(8, 2));
bool flg_leapyear = Judge_LeapYear(year);
bool flg_thirty_first = Judge_ThirtyFirst(month);
bool over_month = false;
switch (day) {
case 27:
if (month == 2 && flg_leapyear == false) {
day = 1;
over_month = true;
}
else {
day = 29;
}
break;
case 28:
if (month == 2) {
if (flg_leapyear) {
day = 1;
}
else {
day = 2;
}
over_month = true;
}
else {
day = 30;
}
break;
case 29:
if (month == 2) {
day = 2;
over_month = true;
}
else if (flg_thirty_first == false) {
day = 1;
over_month = true;
}
else {
day = 31;
}
break;
case 30:
if (flg_thirty_first == false) {
day = 2;
}
else {
day = 1;
}
over_month = true;
break;
case 31:
day = 2;
over_month = true;
break;
default:
day = day + 2;
}
if (over_month) {
if (month == 12) {
month = 1;
year = year + 1;
}
else {
month = month + 1;
}
}
std::cout << year << '/';
std::cout << std::setw(2) << std::setfill('0') << month << '/';
std::cout << std::setw(2) << std::setfill('0') << day << std::endl;
return 0;
}
dgd1724