結果
問題 | No.87 Advent Calendar Problem |
ユーザー |
![]() |
提出日時 | 2014-12-07 00:21:18 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 118 ms / 5,000 ms |
コード長 | 690 bytes |
コンパイル時間 | 1,696 ms |
コンパイル使用メモリ | 74,228 KB |
実行使用メモリ | 41,764 KB |
最終ジャッジ日時 | 2024-06-11 15:54:46 |
合計ジャッジ時間 | 5,523 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
package no87;import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);long n = sc.nextLong() - 2014;int[] count = new int[400];count[0] = 1;int youbi = 0;for(int i=1;i<400;i++) {youbi = (youbi + (isUruu(2014+ i) ? 366 : 365)) % 7;count[i] = count[i-1] + (youbi == 0 ? 1 : 0);}long ans = 0;ans += (n / 400) * count[399];n %= 400;ans += count[(int) n%400];System.out.println(ans-1);}public static boolean isUruu(long y) {if (y%400 == 0) {return true;}else if(y%100 == 0) {return false;}else{return y%4 == 0;}}}