結果

問題 No.87 Advent Calendar Problem
ユーザー mobius_bkstmobius_bkst
提出日時 2015-05-03 18:17:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 1,177 bytes
コンパイル時間 3,378 ms
コンパイル使用メモリ 73,136 KB
実行使用メモリ 49,584 KB
最終ジャッジ日時 2023-09-19 05:16:26
合計ジャッジ時間 5,754 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,104 KB
testcase_01 AC 44 ms
49,252 KB
testcase_02 AC 44 ms
49,488 KB
testcase_03 AC 45 ms
49,292 KB
testcase_04 AC 44 ms
49,156 KB
testcase_05 AC 43 ms
49,420 KB
testcase_06 AC 44 ms
49,252 KB
testcase_07 AC 44 ms
49,008 KB
testcase_08 AC 44 ms
47,404 KB
testcase_09 AC 44 ms
49,160 KB
testcase_10 AC 45 ms
49,364 KB
testcase_11 AC 45 ms
49,584 KB
testcase_12 AC 45 ms
49,108 KB
testcase_13 AC 45 ms
49,412 KB
testcase_14 AC 46 ms
49,176 KB
testcase_15 AC 47 ms
49,252 KB
testcase_16 AC 45 ms
49,360 KB
testcase_17 AC 45 ms
49,240 KB
testcase_18 AC 44 ms
49,164 KB
testcase_19 AC 44 ms
49,216 KB
testcase_20 AC 46 ms
49,272 KB
testcase_21 AC 45 ms
49,168 KB
testcase_22 AC 45 ms
49,176 KB
testcase_23 AC 44 ms
49,256 KB
testcase_24 AC 44 ms
49,172 KB
testcase_25 AC 45 ms
49,124 KB
testcase_26 AC 45 ms
49,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * ツェラーの公式だかってやつで年月日が分かると曜日が分かるやつ
 *
 */
public class No087 {

    private static final int WED = 3;

    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    System.in));
            long y_end = Long.parseLong(br.readLine());
            long Y;
            int m = 7;
            int d = 23;
            long C;
            long ganma;
            long D = 0;
            long b = (y_end - 2014) / 400;
            long count = b * 57;

            for (long i = 2015 + b * 400; i <= y_end; i++) {
                Y = i % 100;
                C = i / 100;
                ganma = (5 * C) + C / 4;
                D = ((d + ((26 * (m + 1)) / 10 + Y + Y / 4 + ganma + 5)) % 7) + 1;
                if (D == WED) {
                    count++;
                }
            }

            System.out.println(count);
            br.close();
        } catch (Exception e) {

            System.err.println("Error:" + e.getMessage());
        }
    }

}
0