結果

問題 No.680 作れる数
ユーザー kohei2019kohei2019
提出日時 2022-07-27 01:42:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 71,484 KB
最終ジャッジ日時 2023-09-23 15:16:44
合計ジャッジ時間 2,840 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,300 KB
testcase_01 AC 76 ms
71,484 KB
testcase_02 AC 77 ms
71,096 KB
testcase_03 AC 78 ms
71,060 KB
testcase_04 AC 76 ms
71,252 KB
testcase_05 AC 75 ms
71,076 KB
testcase_06 AC 76 ms
71,156 KB
testcase_07 AC 74 ms
71,392 KB
testcase_08 AC 73 ms
71,384 KB
testcase_09 AC 74 ms
70,764 KB
testcase_10 AC 75 ms
71,272 KB
testcase_11 AC 74 ms
70,908 KB
testcase_12 AC 78 ms
70,912 KB
testcase_13 AC 75 ms
71,144 KB
testcase_14 AC 76 ms
71,156 KB
testcase_15 AC 74 ms
71,272 KB
testcase_16 AC 75 ms
71,276 KB
testcase_17 AC 74 ms
70,912 KB
testcase_18 AC 74 ms
71,036 KB
testcase_19 AC 74 ms
70,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
# tの値を決めればsは一意に決まる→二分探索
if N == 0:
    print('YES')
    exit()
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