結果

問題 No.87 Advent Calendar Problem
ユーザー htensaihtensai
提出日時 2020-05-13 13:55:34
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 668 bytes
コンパイル時間 2,002 ms
コンパイル使用メモリ 70,888 KB
実行使用メモリ 58,288 KB
最終ジャッジ日時 2023-10-12 16:59:22
合計ジャッジ時間 6,843 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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