結果

問題 No.87 Advent Calendar Problem
ユーザー maimai
提出日時 2016-06-26 16:42:18
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 228 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 11,268 KB
実行使用メモリ 15,332 KB
最終ジャッジ日時 2023-08-27 06:19:50
合計ジャッジ時間 3,536 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,096 KB
testcase_01 AC 82 ms
15,240 KB
testcase_02 AC 82 ms
15,112 KB
testcase_03 AC 82 ms
15,148 KB
testcase_04 AC 81 ms
14,996 KB
testcase_05 AC 84 ms
15,156 KB
testcase_06 AC 81 ms
15,124 KB
testcase_07 AC 82 ms
15,020 KB
testcase_08 AC 84 ms
15,056 KB
testcase_09 AC 81 ms
15,224 KB
testcase_10 AC 82 ms
15,332 KB
testcase_11 AC 83 ms
15,220 KB
testcase_12 AC 82 ms
15,092 KB
testcase_13 AC 82 ms
15,052 KB
testcase_14 AC 83 ms
15,100 KB
testcase_15 AC 83 ms
15,252 KB
testcase_16 AC 83 ms
15,104 KB
testcase_17 AC 81 ms
15,128 KB
testcase_18 AC 82 ms
15,204 KB
testcase_19 AC 81 ms
15,116 KB
testcase_20 AC 82 ms
15,096 KB
testcase_21 AC 82 ms
15,324 KB
testcase_22 AC 84 ms
15,224 KB
testcase_23 AC 82 ms
15,264 KB
testcase_24 AC 82 ms
15,148 KB
testcase_25 AC 83 ms
15,100 KB
testcase_26 AC 82 ms
15,152 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i-2015

memo=Array.new(400,0)

diff=0
400.times{|dy|
    y=dy+2015
    diff+=(((y%4==0 && y%100!=0) || y%400==0) ? 2 : 1)
    memo[dy]=diff%7==0 ? 1 : 0
}

ans=memo.inject(:+)*(n/400)
p ans+memo[0..(n%400)].inject(:+)
0