結果

問題 No.1286 Stone Skipping
ユーザー NoneNone
提出日時 2021-05-01 07:17:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 77,204 KB
最終ジャッジ日時 2023-09-26 15:08:05
合計ジャッジ時間 5,822 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
76,832 KB
testcase_01 AC 92 ms
76,968 KB
testcase_02 AC 102 ms
77,064 KB
testcase_03 AC 96 ms
77,120 KB
testcase_04 AC 95 ms
76,988 KB
testcase_05 AC 96 ms
77,084 KB
testcase_06 AC 100 ms
77,124 KB
testcase_07 AC 99 ms
77,016 KB
testcase_08 AC 99 ms
77,052 KB
testcase_09 AC 98 ms
76,980 KB
testcase_10 AC 98 ms
77,060 KB
testcase_11 AC 99 ms
76,696 KB
testcase_12 AC 97 ms
77,084 KB
testcase_13 AC 97 ms
77,108 KB
testcase_14 AC 98 ms
77,020 KB
testcase_15 AC 96 ms
76,992 KB
testcase_16 AC 100 ms
77,204 KB
testcase_17 AC 99 ms
77,028 KB
testcase_18 AC 92 ms
76,860 KB
testcase_19 AC 91 ms
76,672 KB
testcase_20 AC 96 ms
76,812 KB
testcase_21 AC 94 ms
77,032 KB
testcase_22 AC 96 ms
77,012 KB
testcase_23 AC 99 ms
77,104 KB
testcase_24 AC 100 ms
76,824 KB
testcase_25 AC 103 ms
76,696 KB
testcase_26 AC 104 ms
77,132 KB
testcase_27 AC 101 ms
77,016 KB
testcase_28 AC 100 ms
77,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def binary_search_int(ok, ng, test):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid):
            ok = mid
        else:
            ng = mid
    return ok

def f(x):
    _res=0
    for _ in range(k):
        _res+=x
        x//=2
    return _res

##############################################################

import sys
input = sys.stdin.readline

def test(x):
    return f(x)<=D

D=int(input())

res=float("inf")
for k in range(1,60):
    tmp=binary_search_int(0,10**19,test)
    if f(tmp)==D:
        res=min(tmp,res)

print(res)
0