結果

問題 No.1286 Stone Skipping
コンテスト
ユーザー None
提出日時 2021-05-01 07:17:11
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 687 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 215 ms
コンパイル使用メモリ 85,104 KB
実行使用メモリ 162,376 KB
最終ジャッジ日時 2026-04-02 15:45:34
合計ジャッジ時間 2,274 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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