結果

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

ソースコード

diff #

D = int(input())
ok = pow(10,18)*2
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

while True:
    if verify(ans,D):
        print(ans)
        break
    else:
        ans += 1
0