結果

問題 No.1286 Stone Skipping
ユーザー shotoyooshotoyoo
提出日時 2020-11-13 21:42:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 65,996 KB
最終ジャッジ日時 2024-07-23 09:50:31
合計ジャッジ時間 2,472 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


d = int(input())
ans = d
def sub(x, k):
    v = 0
    i = 0
    for i in range(k):
        v += x
        x //= 2
    return v>=d
def val(x, k):
    v = 0
    i = 0
    for i in range(k):
        v += x
        x //= 2
    return v
def proc(k):
    l = 0
    r = d
    while l<r-1:
        m = (l+r)//2
        if sub(m,k):
            r = m
        else:
            l = m
    if val(r,k)==d:
        return r
    else:
        return None
for v in range(1,100):
    tmp = proc(v)
#     print(tmp)
    if tmp is not None:
        ans = min(ans, tmp)
print(ans)
0