結果

問題 No.2534 コラッツ数列
ユーザー なえしらなえしら
提出日時 2023-11-10 21:45:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 307 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-09-26 01:20:47
合計ジャッジ時間 2,263 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

cnt = 0
op = 1
while cnt <= 50:
  match op:
    case 1:
      cnt += 1
      op = 2
    case 2:
      cnt += 1
      op = N==1 and 4 or 3
    case 3:
      N = N%2 and 3*N+1 or N//2
      cnt += 1
      op = 2
    case 4:
      print("Yes")
      print(cnt)
      break
else:
  print("No")
0