結果

問題 No.1286 Stone Skipping
ユーザー ygd.
提出日時 2020-11-13 21:55:07
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 720 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 81,024 KB
最終ジャッジ日時 2024-07-22 20:46:31
合計ジャッジ時間 5,095 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

D = int(input())
ok = pow(10,20)
ng = 0

def check(x):
    ret = x
    while x > 0:
        x = x//2
        ret += x
    return ret
cnt = 0
while abs(ok-ng) > 1: #and cnt < 100:
    mid = (ok+ng)//2
    #print(ok,mid,ng)
    if check(mid) >= D:
        ok = mid
    else:
        ng = mid
    cnt += 1
ans = ok
#print(ans)

def verify(x,y):
    ret = x
    while x > 0:
        if ret == y:
            return True
        else:
            x = x//2
            ret += x
    if ret == y:
        return True
    else:
        return False
a = ans + 0
b = ans - 0

while True:
    if verify(a,D):
        print(a)
        break
    elif verify(b,D):
        print(b)
        break
    else:
        a += 1
        b -= 1
0