結果

問題 No.87 Advent Calendar Problem
ユーザー GrenacheGrenache
提出日時 2015-11-22 17:37:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 4,071 ms
コンパイル使用メモリ 74,500 KB
実行使用メモリ 58,108 KB
最終ジャッジ日時 2023-10-11 18:15:18
合計ジャッジ時間 8,954 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,756 KB
testcase_01 AC 123 ms
55,784 KB
testcase_02 AC 125 ms
55,708 KB
testcase_03 AC 123 ms
56,032 KB
testcase_04 AC 122 ms
55,704 KB
testcase_05 WA -
testcase_06 AC 121 ms
55,704 KB
testcase_07 AC 123 ms
56,076 KB
testcase_08 AC 124 ms
55,768 KB
testcase_09 AC 123 ms
55,984 KB
testcase_10 WA -
testcase_11 AC 126 ms
55,940 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 123 ms
55,672 KB
testcase_16 WA -
testcase_17 AC 124 ms
55,676 KB
testcase_18 WA -
testcase_19 AC 123 ms
55,564 KB
testcase_20 AC 124 ms
55,664 KB
testcase_21 WA -
testcase_22 AC 122 ms
55,852 KB
testcase_23 WA -
testcase_24 AC 124 ms
55,608 KB
testcase_25 AC 122 ms
55,840 KB
testcase_26 AC 126 ms
55,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder87 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        int ret = 0;
        long tmp = 0;
        for (long i = 2015; i <= Math.min(2400, n); i++) {
        	if ((i % 4 == 0 && i % 100 != 0) || (i % 4 == 0 && i % 400 == 0)) {
        		tmp += 2;
        	} else {
        		tmp += 1;
        	}

        	if (tmp % 7 == 0) {
        		ret++;
        	}
        }

        if (n > 2400) {
        	int[] wed = new int[400 + 1];
        	for (long i = 2401; i <= 2800; i++) {
            	if (i % 4 == 0 && i % 100 != 0 && i % 400 == 0) {
            		tmp += 2;
            	} else {
            		tmp += 1;
            	}

            	if (tmp % 7 == 0) {
            		wed[(int)(i - 2400)] = wed[(int)(i - 1 - 2400)] + 1;
            	} else {
            		wed[(int)(i - 2400)] = wed[(int)(i - 1 - 2400)];
            	}
        	}

        	ret += (n - 2400) / 400 * wed[400] + wed[(int)((n - 2400) % 400)];
        }

        System.out.println(ret);

        sc.close();
    }
}
0