結果

問題 No.588 空白と回文
ユーザー htkbhtkb
提出日時 2017-11-03 23:49:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 386 bytes
コンパイル時間 465 ms
コンパイル使用メモリ 10,588 KB
実行使用メモリ 8,112 KB
最終ジャッジ日時 2023-08-15 09:10:50
合計ジャッジ時間 1,788 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 WA -
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 RE -
testcase_24 RE -
権限があれば一括ダウンロードができます

ソースコード

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
            y = N-2 if (N-1)%4 == 0 else N-4
            y -= x + 2
            print(n + max(y*2, 0))


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