結果

問題 No.87 Advent Calendar Problem
ユーザー YamaKasa
提出日時 2018-10-17 03:49:06
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 717 bytes
コンパイル時間 2,257 ms
コンパイル使用メモリ 76,772 KB
実行使用メモリ 56,196 KB
最終ジャッジ日時 2024-10-12 18:49:49
合計ジャッジ時間 6,679 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 RE * 18
権限があれば一括ダウンロードができます

ソースコード

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