結果

問題 No.87 Advent Calendar Problem
ユーザー ぴろずぴろず
提出日時 2014-12-07 00:21:18
言語 Java19
(openjdk 21)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 690 bytes
コンパイル時間 2,077 ms
コンパイル使用メモリ 72,364 KB
実行使用メモリ 56,736 KB
最終ジャッジ日時 2023-09-02 09:04:54
合計ジャッジ時間 6,712 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,988 KB
testcase_01 AC 119 ms
55,820 KB
testcase_02 AC 118 ms
55,860 KB
testcase_03 AC 120 ms
55,992 KB
testcase_04 AC 120 ms
55,708 KB
testcase_05 AC 120 ms
55,820 KB
testcase_06 AC 121 ms
55,712 KB
testcase_07 AC 120 ms
55,900 KB
testcase_08 AC 120 ms
55,936 KB
testcase_09 AC 120 ms
55,736 KB
testcase_10 AC 119 ms
55,520 KB
testcase_11 AC 120 ms
56,120 KB
testcase_12 AC 119 ms
56,536 KB
testcase_13 AC 118 ms
55,748 KB
testcase_14 AC 118 ms
55,716 KB
testcase_15 AC 118 ms
55,512 KB
testcase_16 AC 119 ms
55,988 KB
testcase_17 AC 119 ms
56,192 KB
testcase_18 AC 119 ms
55,688 KB
testcase_19 AC 120 ms
55,968 KB
testcase_20 AC 120 ms
56,736 KB
testcase_21 AC 119 ms
55,952 KB
testcase_22 AC 117 ms
55,708 KB
testcase_23 AC 122 ms
55,800 KB
testcase_24 AC 118 ms
55,452 KB
testcase_25 AC 119 ms
55,840 KB
testcase_26 AC 118 ms
55,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
		}
	}

}
0