結果

問題 No.305 鍵(2)
ユーザー Cos5XCos5X
提出日時 2015-11-27 23:19:47
言語 Ruby
(3.3.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 11,200 KB
実行使用メモリ 31,488 KB
平均クエリ数 52.69
最終ジャッジ日時 2023-09-23 22:03:58
合計ジャッジ時間 2,661 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
31,184 KB
testcase_01 AC 111 ms
31,388 KB
testcase_02 AC 110 ms
31,052 KB
testcase_03 AC 109 ms
30,752 KB
testcase_04 AC 109 ms
30,792 KB
testcase_05 AC 113 ms
30,640 KB
testcase_06 AC 108 ms
30,792 KB
testcase_07 AC 112 ms
30,640 KB
testcase_08 AC 111 ms
30,864 KB
testcase_09 AC 110 ms
30,764 KB
testcase_10 AC 108 ms
30,916 KB
testcase_11 AC 110 ms
31,488 KB
testcase_12 AC 111 ms
31,080 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - i
Syntax OK

ソースコード

diff #

i = 0
key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
prev = nil
now = 0
loop do
  puts key.join
  STDOUT.flush
  a, s = gets.split(' ')
  break if s == "unlocked"

  if prev.nil?
    prev = a
  elsif prev > a
    key[now] = (key[now]+9)%10
    now += 1
  elsif prev < a
    now += 1
  end
  now = 0 if now > 9

  prev = a
  key[now] = (key[now]+1)%10
end
0