結果

問題 No.87 Advent Calendar Problem
ユーザー HiroakiSoftwareHiroakiSoftware
提出日時 2014-12-07 00:21:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,157 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 26,544 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-02 09:05:17
合計ジャッジ時間 20,986 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//yukicoder87
//作成者:ヒロソフ
//2014年7月23日と同じ曜日(水曜日)となる回数を求めよ
#include <stdio.h>

#define START_YEAR 2015
#define TARGET_MONTH 7
#define TARGET_DAY 23

int GetMJD(int year, int month, int day);
int GetDayOfWeekByMJD(int mjd);

int main(void) {

	//ターゲットの曜日を示す値(水曜日が0なので注意)
	int TargetDayofWeek = GetDayOfWeekByMJD(GetMJD(2014, TARGET_MONTH, TARGET_DAY));

	int EndYear;
	int count = 0;
	scanf("%d", &EndYear);

	for (int i = START_YEAR; i <= EndYear; i++) {
		if (GetDayOfWeekByMJD(GetMJD(i, TARGET_MONTH, TARGET_DAY)) == TargetDayofWeek) {
			count++;
		}
	}

	printf("%d\n", count);
	return 0;
}

/*
	フリーゲルの公式で修正ユリウス日に変換
*/
int GetMJD(int year, int month, int day) {

	if (month <= 2) {
		year--;
		month += 12;
	}

	int ret;

	ret = (int)(365.25 * year);
	ret += year / 400;
	ret -= year / 100;
	ret += (int)(30.59 * (month - 2)) + day;
	ret -= 678912;

	return ret;
}

int GetDayOfWeekByMJD(int mjd) {
	int ret = mjd % 7;
	if (ret < 0) ret += 7;
	return ret;
}
0