結果

問題 No.87 Advent Calendar Problem
ユーザー htensaihtensai
提出日時 2020-05-13 13:56:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 670 bytes
コンパイル時間 2,069 ms
コンパイル使用メモリ 71,724 KB
実行使用メモリ 58,044 KB
最終ジャッジ日時 2023-10-12 16:59:30
合計ジャッジ時間 6,741 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,808 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 124 ms
55,796 KB
testcase_04 AC 127 ms
55,428 KB
testcase_05 AC 125 ms
55,872 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 128 ms
55,852 KB
testcase_10 AC 127 ms
55,460 KB
testcase_11 WA -
testcase_12 AC 131 ms
55,716 KB
testcase_13 AC 128 ms
53,640 KB
testcase_14 AC 127 ms
55,676 KB
testcase_15 WA -
testcase_16 AC 126 ms
55,432 KB
testcase_17 WA -
testcase_18 AC 124 ms
55,876 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 128 ms
55,876 KB
testcase_23 AC 126 ms
55,684 KB
testcase_24 AC 126 ms
55,820 KB
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