結果

問題 No.680 作れる数
ユーザー kohei2019kohei2019
提出日時 2022-07-27 01:41:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 71,444 KB
最終ジャッジ日時 2023-09-23 15:14:47
合計ジャッジ時間 3,094 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,260 KB
testcase_01 AC 74 ms
71,168 KB
testcase_02 AC 73 ms
71,272 KB
testcase_03 AC 72 ms
71,084 KB
testcase_04 AC 74 ms
71,280 KB
testcase_05 AC 73 ms
71,388 KB
testcase_06 AC 74 ms
70,776 KB
testcase_07 AC 74 ms
71,084 KB
testcase_08 AC 76 ms
71,088 KB
testcase_09 AC 77 ms
71,388 KB
testcase_10 WA -
testcase_11 AC 74 ms
71,188 KB
testcase_12 AC 75 ms
70,780 KB
testcase_13 AC 74 ms
71,168 KB
testcase_14 AC 74 ms
71,352 KB
testcase_15 AC 74 ms
71,192 KB
testcase_16 AC 72 ms
71,248 KB
testcase_17 AC 75 ms
71,248 KB
testcase_18 AC 75 ms
71,296 KB
testcase_19 AC 76 ms
71,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
# tの値を決めればsは一意に決まる→二分探索
def is_ok(arg):
    val = 0
    bia = bin(arg)[2:]
    for j in range(1,len(bia)+1):
        val += int(bia[:j],2)
    return N <= val
 
 
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
arg = meguru_bisect(0,10**10)
val = 0
bia = bin(arg)[2:]
for j in range(1,len(bia)+1):
    val += int(bia[:j],2)
print('YES' if val == N else 'NO')

0