結果

問題 No.589 Counting Even
ユーザー ntuda
提出日時 2025-08-16 15:42:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 206 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 82,600 KB
実行使用メモリ 54,188 KB
最終ジャッジ日時 2025-08-16 15:42:44
合計ジャッジ時間 2,722 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N):
    if N == 0:
        return 0

    nc = N.bit_count()
    a = 2
    cnt = 2
    for i in range(nc-1):
        cnt += a
        a *= 2
    return N + 1 - cnt

N = int(input())
print(solve(N))
0