結果

問題 No.1286 Stone Skipping
ユーザー lllllll88938494
提出日時 2023-04-28 14:22:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 434 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 82,488 KB
実行使用メモリ 58,928 KB
最終ジャッジ日時 2024-11-17 14:44:31
合計ジャッジ時間 2,439 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

d = int(input())
ng = 0
ok = d

def  cal(a):
    cnt = 0
    while a:
        cnt += a
        a//=2
    return cnt

def  cal2(a):
    cnt = 0
    while a:
        cnt += a
        a//=2
        if cnt == d:
            return True
    return False

ans = d
while ok - ng > 1:
    mid = (ok + ng)//2
    if  cal(mid) >= d:
        ok = mid
    else:
        ng = mid

    if cal2(mid):
        ans = min(ans,mid)
        

print(ans)
0