結果

問題 No.87 Advent Calendar Problem
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-04-09 15:21:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 1,113 bytes
コンパイル時間 3,473 ms
コンパイル使用メモリ 74,540 KB
実行使用メモリ 56,372 KB
最終ジャッジ日時 2023-09-17 19:02:34
合計ジャッジ時間 7,826 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,068 KB
testcase_01 AC 125 ms
55,408 KB
testcase_02 AC 126 ms
55,736 KB
testcase_03 AC 125 ms
55,848 KB
testcase_04 AC 124 ms
55,588 KB
testcase_05 AC 124 ms
55,888 KB
testcase_06 AC 125 ms
55,756 KB
testcase_07 AC 124 ms
55,728 KB
testcase_08 AC 124 ms
56,136 KB
testcase_09 AC 124 ms
55,748 KB
testcase_10 AC 125 ms
56,040 KB
testcase_11 AC 124 ms
55,624 KB
testcase_12 AC 126 ms
56,372 KB
testcase_13 AC 125 ms
56,104 KB
testcase_14 AC 125 ms
55,960 KB
testcase_15 AC 125 ms
55,624 KB
testcase_16 AC 125 ms
56,028 KB
testcase_17 AC 126 ms
55,976 KB
testcase_18 AC 124 ms
56,216 KB
testcase_19 AC 123 ms
56,300 KB
testcase_20 AC 125 ms
55,984 KB
testcase_21 AC 123 ms
55,740 KB
testcase_22 AC 123 ms
56,128 KB
testcase_23 AC 122 ms
55,848 KB
testcase_24 AC 123 ms
55,972 KB
testcase_25 AC 126 ms
56,208 KB
testcase_26 AC 124 ms
56,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//No.87 Advent Calendar Problem

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class No87 {
    
    static final Scanner in = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        long n = in.nextLong()-2014;
        int w = zeller(2014,7,23);
        long cnt = n/400*57;
        n %= 400;
        
        for (int i=2015; i<2015+n; i++) {
            if (w == zeller(i,7,23)) cnt++;
        }
        out.println(cnt);
    }

    static int zeller(int y, int m, int d) {
        if (m <= 2) {
            y--; m+=12;
        }
        int a = y/100;
        int b = y%100;
        return (d+26*(m+1)/10+b+b/4+a/4+5*a)%7;
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        in.close();
        out.close();
    }

    static void trace(Object... o) { System.out.println(deepToString(o));}
}
0