結果

問題 No.2241 Reach 1
ユーザー lam6er
提出日時 2025-04-16 16:43:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 53,328 KB
最終ジャッジ日時 2025-04-16 16:45:10
合計ジャッジ時間 2,441 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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