結果

問題 No.87 Advent Calendar Problem
ユーザー tsukiotsukio
提出日時 2016-03-06 19:39:51
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 814 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 56,580 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 20:09:11
合計ジャッジ時間 1,273 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

enum DayOfWeek {
	Sunday,
	Monday,
	Tuesday,
	Wednesday,
	Thursday,
	Friday,
	Saturday,
};

int Zeller(int y, int m, int d)
{
	if (m < 3) {
		y--; m += 12;
	}
	return (y + y / 4 - y / 100 + y / 400 + (13 * m + 8) / 5 + d) % 7;
}

int main() {
	DayOfWeek day_of_week_table[] = { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday };

	long long n;
	cin >> n;

	long long num_of_years = n - 2015 + 1;
	long long count = 0;
	
	if (n > 400) {
		for (int year = 1; year <= 400; year++) {
			if (day_of_week_table[Zeller(year, 7, 23)] == Wednesday)
				count++;
		}
		count *= num_of_years / 400;
	}

	for (int i = 0; i < num_of_years % 400; i++) {
		if (day_of_week_table[Zeller(2015 + i, 7, 23)] == Wednesday)
			count++;
	}

	cout << count << endl;

	return 0;
}
0