結果
問題 | No.87 Advent Calendar Problem |
ユーザー |
|
提出日時 | 2017-02-26 10:18:15 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 83 ms / 5,000 ms |
コード長 | 883 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-06-11 16:33:37 |
合計ジャッジ時間 | 3,091 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
Main.rb:9: warning: assigned but unused variable - res Syntax OK
ソースコード
require 'date'class Yukicoderdef initialize@n = gets.to_ienddef runres = 0# 28以下の端数の計算first_span = Array.new(2400-2014 + 1, 0)first_cnt = 0wday = 02015.upto(2400) do |i|if i % 400 == 0 || i % 4 == 0 && i % 100 != 0wday += 2elsewday += 1endwday %= 7first_cnt += 1 if wday == 0first_span[i-2014] = first_cntendspan_2800 = Array.new(2800, 0)cnt = 01.upto(2799) do |i|if i % 400 == 0 || i % 4 == 0 && i % 100 != 0wday += 2elsewday += 1endwday %= 7cnt += 1 if wday == 0span_2800[i] = cntendif @n <= 2400return first_span[@n-2014]elsereturn first_cnt + (@n - 2400) / 2800 * cnt + span_2800[(@n - 2400) % 2800]endendendputs Yukicoder.new.run