結果

問題 No.887 Collatz
ユーザー varrho
提出日時 2019-09-20 21:34:52
言語 Nim
(2.2.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 211 bytes
コンパイル時間 3,363 ms
コンパイル使用メモリ 65,444 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 16:41:41
合計ジャッジ時間 4,364 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils
var
  n: int = stdin.readline.parseInt
  cnt: int = 0
  nmax: int = n
while n != 1:
  cnt.inc
  if n mod 2 == 0:
    n = n div 2
  else:
    n = 3 * n + 1
  nmax = max(nmax, n)
echo cnt
echo nmax
0