結果

問題 No.740 幻の木
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2018-10-14 10:42:06
言語 Ruby
(3.3.0)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 325 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-20 20:15:41
合計ジャッジ時間 1,685 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
12,032 KB
testcase_01 AC 79 ms
12,160 KB
testcase_02 AC 79 ms
12,160 KB
testcase_03 AC 79 ms
12,160 KB
testcase_04 AC 77 ms
12,160 KB
testcase_05 AC 77 ms
12,288 KB
testcase_06 AC 286 ms
12,160 KB
testcase_07 AC 78 ms
12,288 KB
testcase_08 AC 79 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, M, P, Q = gets.split.map(&:to_i)

month = 1
month_count = 0
loop do
  month_count += 1
  n -= M

  if P + Q > 12
    n -= M if month.between?(P, 12) || month.between?(1, (P + Q - 1) % 12)
  elsif month.between?(P, P + Q - 1)
    n -= M
  end

  break if n <= 0

  month += 1
  month = 1 if month > 12
end

puts month_count
0