結果

問題 No.87 Advent Calendar Problem
ユーザー cielciel
提出日時 2014-12-07 00:15:14
言語 Ruby
(3.2.2)
結果
AC  
実行時間 85 ms / 5,000 ms
コード長 389 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 11,500 KB
実行使用メモリ 15,344 KB
最終ジャッジ日時 2023-09-02 09:03:11
合計ジャッジ時間 3,475 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,344 KB
testcase_01 AC 84 ms
15,120 KB
testcase_02 AC 81 ms
15,248 KB
testcase_03 AC 80 ms
15,004 KB
testcase_04 AC 80 ms
15,128 KB
testcase_05 AC 85 ms
15,068 KB
testcase_06 AC 80 ms
15,148 KB
testcase_07 AC 83 ms
15,340 KB
testcase_08 AC 83 ms
15,272 KB
testcase_09 AC 83 ms
15,128 KB
testcase_10 AC 83 ms
15,280 KB
testcase_11 AC 82 ms
15,060 KB
testcase_12 AC 80 ms
15,096 KB
testcase_13 AC 82 ms
15,088 KB
testcase_14 AC 82 ms
15,312 KB
testcase_15 AC 78 ms
15,280 KB
testcase_16 AC 80 ms
15,072 KB
testcase_17 AC 78 ms
15,204 KB
testcase_18 AC 80 ms
15,056 KB
testcase_19 AC 82 ms
15,288 KB
testcase_20 AC 80 ms
15,004 KB
testcase_21 AC 79 ms
15,288 KB
testcase_22 AC 79 ms
15,008 KB
testcase_23 AC 82 ms
15,116 KB
testcase_24 AC 80 ms
15,176 KB
testcase_25 AC 80 ms
15,248 KB
testcase_26 AC 82 ms
15,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def zeller(_y,m,d)
	m+=1
	if m<4 then _y-=1;m+=12 end
	y=_y/100;z=_y%100
	(5*y+z+y/4+z/4+13*m/5+d-1)%7
end
day=zeller(2014,7,23)
n=gets.to_i
if n<=5600
p (2015..n).count{|i|zeller(i,7,23)==zeller(2014,7,23)}
else
cycle=(2800...5600).count{|i|zeller(i,7,23)==day}
p (2015...2800).count{|i|zeller(i,7,23)==day}+(n/2800-1)*cycle+(n/2800*2800..n).count{|i|zeller(i,7,23)==day}
end
0