結果
| 問題 | No.87 Advent Calendar Problem | 
| コンテスト | |
| ユーザー |  t8m8⛄️ | 
| 提出日時 | 2015-04-09 15:21:37 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 134 ms / 5,000 ms | 
| コード長 | 1,113 bytes | 
| コンパイル時間 | 3,589 ms | 
| コンパイル使用メモリ | 77,724 KB | 
| 実行使用メモリ | 41,720 KB | 
| 最終ジャッジ日時 | 2024-07-04 13:25:50 | 
| 合計ジャッジ時間 | 8,139 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 24 | 
ソースコード
//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));}
}
            
            
            
        