結果

問題 No.2241 Reach 1
ユーザー lam6er
提出日時 2025-04-16 01:02:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 81,736 KB
実行使用メモリ 53,012 KB
最終ジャッジ日時 2025-04-16 01:04:04
合計ジャッジ時間 2,400 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
cnt = 0

# Divide by the maximum possible power of 2 each time
while n % 2 == 0:
    lsb = n & -n  # Find the least significant bit (max power of 2 dividing n)
    n //= lsb
    cnt += 1

# If the remaining n is greater than 1, add 2 operations (multiply and add 1, then divide)
if n > 1:
    cnt += 2

print(cnt)
0