結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー simansiman
提出日時 2020-12-08 16:56:45
言語 Ruby
(3.3.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 236 bytes
コンパイル時間 51 ms
コンパイル使用メモリ 11,200 KB
実行使用メモリ 31,524 KB
平均クエリ数 3.70
最終ジャッジ日時 2023-09-24 02:49:27
合計ジャッジ時間 4,954 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
31,452 KB
testcase_01 AC 105 ms
31,272 KB
testcase_02 AC 102 ms
31,524 KB
testcase_03 AC 109 ms
31,132 KB
testcase_04 AC 107 ms
30,948 KB
testcase_05 AC 102 ms
31,072 KB
testcase_06 AC 104 ms
30,972 KB
testcase_07 AC 104 ms
30,712 KB
testcase_08 AC 104 ms
30,884 KB
testcase_09 AC 104 ms
30,988 KB
testcase_10 AC 113 ms
30,892 KB
testcase_11 AC 110 ms
30,868 KB
testcase_12 AC 113 ms
30,940 KB
testcase_13 AC 105 ms
31,376 KB
testcase_14 AC 105 ms
31,232 KB
testcase_15 AC 104 ms
31,336 KB
testcase_16 AC 106 ms
31,240 KB
testcase_17 AC 108 ms
31,088 KB
testcase_18 AC 105 ms
31,332 KB
testcase_19 AC 104 ms
31,084 KB
testcase_20 AC 105 ms
31,336 KB
testcase_21 AC 103 ms
30,748 KB
testcase_22 AC 105 ms
31,012 KB
testcase_23 AC 108 ms
31,340 KB
testcase_24 AC 108 ms
31,276 KB
testcase_25 AC 109 ms
31,056 KB
testcase_26 AC 103 ms
30,668 KB
testcase_27 AC 106 ms
31,156 KB
testcase_28 AC 104 ms
30,724 KB
testcase_29 AC 103 ms
31,184 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:3: warning: assigned but unused variable - first
Syntax OK

ソースコード

diff #

N, K = gets.split.map(&:to_i)
g = a = (N - 1) % (K + 1)
first = (a != 0)

STDOUT.puts(a)
STDOUT.flush
turn = 0

loop {
  turn += 1
  b = gets.to_i
  break if b >= N

  a = (g + (K + 1) * turn) - b

  STDOUT.puts(b + a)
  STDOUT.flush
}
0