結果

問題 No.1286 Stone Skipping
ユーザー komkompikomkompi
提出日時 2023-11-04 10:59:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 81,876 KB
実行使用メモリ 59,140 KB
最終ジャッジ日時 2023-11-04 10:59:08
合計ジャッジ時間 2,464 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
57,068 KB
testcase_01 AC 39 ms
57,068 KB
testcase_02 AC 39 ms
57,068 KB
testcase_03 AC 40 ms
57,068 KB
testcase_04 AC 39 ms
57,068 KB
testcase_05 WA -
testcase_06 AC 39 ms
57,068 KB
testcase_07 AC 38 ms
57,068 KB
testcase_08 AC 39 ms
57,068 KB
testcase_09 AC 39 ms
57,068 KB
testcase_10 AC 39 ms
57,068 KB
testcase_11 AC 39 ms
57,068 KB
testcase_12 AC 39 ms
57,068 KB
testcase_13 AC 39 ms
57,068 KB
testcase_14 AC 39 ms
57,068 KB
testcase_15 WA -
testcase_16 AC 40 ms
57,092 KB
testcase_17 AC 40 ms
57,068 KB
testcase_18 AC 39 ms
57,068 KB
testcase_19 AC 39 ms
57,068 KB
testcase_20 AC 39 ms
57,068 KB
testcase_21 AC 39 ms
57,092 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 39 ms
57,092 KB
testcase_27 AC 40 ms
59,116 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

D=int(input())

MAX_BOUND=64

def calc_distance(init_power):
    rev=0
    while init_power:
        rev+=init_power
        init_power//=2
        
    return rev

ans=D
for k in range(MAX_BOUND):
    high=2**(k+1)-1
    low=2**k
    
    #error判定
    high_distance=calc_distance(high)
    low_distance=calc_distance(low)
    
    if low_distance<=D<=high_distance:
        pass
    else:
        continue
    
    while high-low>1:
        middle=(high+low)//2
        
        distance=calc_distance(middle)
        
        if distance>=D:
            high=middle
        else:
            low=middle
            
    ans=min(ans,high)

print(ans)
0