結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー stone_725stone_725
提出日時 2018-09-06 09:14:13
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,036 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 134,408 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-20 10:54:59
合計ジャッジ時間 2,715 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

bool is_uruu(int year) {
	if (year % 400 == 0) return true;
	if (year % 4 == 0 and year % 100 != 0) return true;
	return false;
}

string getday(int year, int month, int day) {
	stringstream ss;
	ss << year << "/";
	ss << setfill('0') << setw(2);
	ss << month << setw(0);
	ss << "/";
	ss << setfill('0') << setw(2) << day;
	return ss.str();
}

string nextday(string today) {
	int y = stoi(today.substr(0, 4));
	int m = stoi(today.substr(5, 2));
	int d = stoi(today.substr(8, 2));

	if (m == 2 && (d == 28)) {
		if (is_uruu(y)) {
			d++;
		}
		else {
			m++;
			d = 1;
		}
		return getday(y, m, d);
	}
	int days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	if (days[m] == d || (m == 2 && d == 29)) {
		d = 1;
		m++;
		if (m == 13) {
			m = 1;
			y++;
		}
	}
	else {
		d++;
	}
	return getday(y, m, d);
}

void hawawa(){
	string today;
	cin >> today;
	cout << nextday(nextday(today)) << "\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	hawawa();
	return 0;
}
0