結果

問題 No.887 Collatz
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2020-11-09 20:54:05
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 178 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 11,164 KB
実行使用メモリ 15,388 KB
最終ジャッジ日時 2023-09-29 22:15:44
合計ジャッジ時間 4,448 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
15,284 KB
testcase_01 AC 70 ms
15,140 KB
testcase_02 AC 69 ms
15,132 KB
testcase_03 WA -
testcase_04 AC 69 ms
15,128 KB
testcase_05 AC 68 ms
15,276 KB
testcase_06 AC 70 ms
15,280 KB
testcase_07 AC 72 ms
15,032 KB
testcase_08 AC 69 ms
15,356 KB
testcase_09 AC 76 ms
15,160 KB
testcase_10 AC 76 ms
15,084 KB
testcase_11 AC 76 ms
15,040 KB
testcase_12 AC 75 ms
15,280 KB
testcase_13 AC 74 ms
15,276 KB
testcase_14 AC 77 ms
15,112 KB
testcase_15 AC 70 ms
15,168 KB
testcase_16 AC 70 ms
15,384 KB
testcase_17 AC 72 ms
15,312 KB
testcase_18 AC 70 ms
15,160 KB
testcase_19 AC 71 ms
15,284 KB
testcase_20 AC 69 ms
15,168 KB
testcase_21 AC 70 ms
15,176 KB
testcase_22 AC 70 ms
15,032 KB
testcase_23 AC 71 ms
15,328 KB
testcase_24 AC 69 ms
15,232 KB
testcase_25 AC 70 ms
15,172 KB
testcase_26 AC 68 ms
15,104 KB
testcase_27 AC 70 ms
15,332 KB
testcase_28 AC 70 ms
15,252 KB
testcase_29 AC 71 ms
15,080 KB
testcase_30 AC 68 ms
15,312 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = n_max = gets.to_i
i1 = 0

loop do
  if n.odd?
    n = 3 * n + 1
  else
    n /= 2
  end

  n_max = [n_max, n].max
  i1 += 1

  next unless n == 1

  break
end

puts i1, n_max
0