結果

問題 No.1286 Stone Skipping
ユーザー shotoyoo
提出日時 2020-11-13 21:36:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 64,768 KB
最終ジャッジ日時 2024-07-22 20:32:55
合計ジャッジ時間 2,451 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 9 RE * 1
権限があれば一括ダウンロードができます

ソースコード

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
    while x>0:
        v += x
        x //= 2
        i += 1
        if i>=k:
            break
    return v>=d
def val(x, k):
    v = 0
    i = 0
    while x>0:
        v += x
        x //= 2
        i += 1
        if i>=k:
            break
    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(m,k)==d:
        return m
    else:
        return None
for v in range(2,100):
    tmp = proc(v)
    if tmp is not None:
        ans = min(ans, tmp)
print(ans)
0