結果

問題 No.721 Die tertia (ディエ・テルツィア)
ユーザー SSRSSSRS
提出日時 2020-08-04 07:41:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 987 bytes
コンパイル時間 552 ms
コンパイル使用メモリ 66,840 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 05:13:05
合計ジャッジ時間 1,678 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;
bool leap(int Y){
	return Y % 400 == 0 || Y % 100 != 0 && Y % 4 == 0;
}
void next(int &Y, int &M, int &D){
	if (M == 2){
		if (leap(Y)){
			if (D == 29){
				M++;
				D = 1;
			} else {
				D++;
			}
		} else {
			if (D == 28){
				M++;
				D = 1;
			} else {
				D++;
			}
		}
	} else if (M == 4 || M == 6 || M == 9 || M == 11){
		if (D == 30){
			M++;
			D = 1;
		} else {
			D++;
		}
	} else if (M == 12){
		if (D == 31){
			Y++;
			M = 1;
			D = 1;
		} else {
			D++;
		}
	} else {
		if (D == 31){
			M++;
			D = 1;
		} else {
			D++;
		}
	}
}
int main(){
	int Y;
	char s1;
	int M;
	char s2;
	int D;
	cin >> Y >> s1 >> M >> s2 >> D;
	next(Y, M, D);
	next(Y, M, D);
	string Y2 = to_string(Y);
	while (Y2.size() < 4){
		Y2 = '0' + Y2;
	}
	string M2 = to_string(M);
	while (M2.size() < 2){
		M2 = '0' + M2;
	}
	string D2 = to_string(D);
	while (D2.size() < 2){
		D2 = '0' + D2;
	}
	cout << Y2 << s1 << M2 << s2 << D2 << endl;
}
0