結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー dgd1724dgd1724
提出日時 2018-11-24 20:09:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,793 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 65,040 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 04:59:00
合計ジャッジ時間 1,565 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

}
0