結果

問題 No.87 Advent Calendar Problem
ユーザー htensai
提出日時 2020-05-13 13:56:41
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 670 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 79,252 KB
実行使用メモリ 41,548 KB
最終ジャッジ日時 2024-09-14 15:34:46
合計ジャッジ時間 6,354 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		int[] counts = new int[401];
		int mod = 365 % 7;
		for (int i = 0; i < 400; i++) {
		    if (mod == 0) {
		        counts[i]++;
		    }
		    int year = i + 2015;
		    if (year % 4 != 0 && year % 100 == 0) {
		        mod += 365;
		    } else {
		        mod += 366;
		    }
		    mod %= 7;
		}
		for (int i = 1; i < 400; i++) {
		    counts[i] += counts[i - 1];
		}
		long times = (n - 2015) / 400;
		int idx = (int)((n - 2015) % 400);
		long ans = times * counts[399] + counts[idx];
		System.out.println(ans);
	}
}
0