結果

問題 No.588 空白と回文
ユーザー htkb
提出日時 2017-11-03 23:50:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 436 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-23 15:11:04
合計ジャッジ時間 1,579 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 5 RE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    import math
    N = int(input())
    if N < 2:
        print(0)
    elif N%2==0:
        print(N-1)
    else:
        x = 2**int(math.log2(N)) - 1
        if x < N/2:
            print(0)
        else:
            n = x*2-N+1
            if (N-1)%4 == 0:
                y = N-2
            else:
                y = N-4
            y -= x + 2
            print(n + max(y*2, 0))


if __name__ == "__main__":
    solve()
0