結果

問題 No.638 Sum of "not power of 2"
ユーザー kichirb3kichirb3
提出日時 2018-03-07 08:35:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 835 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 11,844 KB
実行使用メモリ 10,024 KB
最終ジャッジ日時 2023-10-25 03:47:54
合計ジャッジ時間 1,326 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 32 ms
10,024 KB
testcase_05 WA -
testcase_06 AC 28 ms
10,024 KB
testcase_07 AC 29 ms
10,024 KB
testcase_08 AC 29 ms
10,024 KB
testcase_09 AC 28 ms
10,024 KB
testcase_10 AC 29 ms
10,024 KB
testcase_11 AC 29 ms
10,024 KB
testcase_12 WA -
testcase_13 AC 30 ms
10,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.638 Sum of "not power of 2"
https://yukicoder.me/problems/no/638

"""
import sys
from sys import stdin
input = stdin.readline


def is_valid(a, b, prohibits):
    if a < 1 or b < 1:
        return False
    if a in prohibits or b in prohibits:
        return False
    return True


def solve(N):
    prohibits = set([])
    for i in range(64):
        prohibits.add(2**i)

    ans = -1
    for i in range(64):
        t = 2**i

        a = t - 1
        b = N - a
        if is_valid(a, b, prohibits):
            ans = a
            break

        a = t + 1
        b = N - a
        if is_valid(a, b, prohibits):
            ans = a
            break

    return ans


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans, N - ans)


if __name__ == '__main__':
    main(sys.argv[1:])
0