結果

問題 No.1286 Stone Skipping
ユーザー shotoyoo
提出日時 2020-11-13 21:26:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 59,388 KB
最終ジャッジ日時 2024-07-22 20:27:33
合計ジャッジ時間 2,210 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 6
権限があれば一括ダウンロードができます

ソースコード

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())
def sub(x):
    v = x
    while x>0:
        x = x//2
        v += x
    return v>=d
def val(x):
    v = x
    while x>0:
        x = x//2
        v += x
        if v==d:
            return v
    return v
l = 0
r = d
while l<r-1:
    m = (l+r)//2
    if sub(m):
        r = m
    else:
        l = m
# print(r, val(r))
while val(r)>d:
    r -= 1
if val(r)==d:
    print(r)
else:
    print(d)
0