結果

問題 No.87 Advent Calendar Problem
ユーザー YamaKasaYamaKasa
提出日時 2018-10-17 03:49:06
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 717 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 76,560 KB
実行使用メモリ 54,844 KB
最終ジャッジ日時 2024-04-20 20:42:59
合計ジャッジ時間 6,007 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 103 ms
52,744 KB
testcase_03 AC 117 ms
53,768 KB
testcase_04 AC 114 ms
53,772 KB
testcase_05 AC 116 ms
54,160 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 116 ms
53,772 KB
testcase_17 AC 119 ms
53,896 KB
testcase_18 AC 117 ms
53,772 KB
testcase_19 AC 117 ms
53,972 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 107 ms
52,972 KB
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		scan.close();
		int t = N - 2014;
		int h = zeller(2014, 7, 23);
		int cnt = 0;
		for(int i = 0; i < 400; i++) {
			if(h == zeller(2015 + i, 7, 23)) {
				cnt ++;
			}
		}
		int k = t / 400;
		int ans = k * cnt;
		int s = 2015 + k *  400;

		for(int i = s; i <= N; i++) {
			if(h == zeller(i, 7, 23)) {
				ans++;
			}
		}
		System.out.println(ans);

	}
	static int zeller(int y, int m, int d) {
		int t1 = d;
		int t2 = (26 * (m + 1)) / 10;
		int t3 = y % 100 + (y % 100) / 4;
		int t4 = 5 * (y / 100) + (y / 100) / 4;
		return (t1 + t2 + t3 + t4) % 7;
	}
}
0