結果

問題 No.1286 Stone Skipping
ユーザー ntudantuda
提出日時 2021-09-12 22:32:09
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 508 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 76,860 KB
最終ジャッジ日時 2023-09-07 00:35:24
合計ジャッジ時間 5,318 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,928 KB
testcase_01 AC 75 ms
75,912 KB
testcase_02 AC 80 ms
76,612 KB
testcase_03 AC 79 ms
76,068 KB
testcase_04 AC 78 ms
76,144 KB
testcase_05 AC 79 ms
75,924 KB
testcase_06 AC 78 ms
75,996 KB
testcase_07 AC 79 ms
75,984 KB
testcase_08 AC 83 ms
76,612 KB
testcase_09 AC 82 ms
76,640 KB
testcase_10 AC 83 ms
76,604 KB
testcase_11 AC 80 ms
76,424 KB
testcase_12 AC 81 ms
76,772 KB
testcase_13 AC 80 ms
76,660 KB
testcase_14 AC 80 ms
76,496 KB
testcase_15 AC 81 ms
76,488 KB
testcase_16 AC 80 ms
76,608 KB
testcase_17 AC 81 ms
76,860 KB
testcase_18 AC 82 ms
76,752 KB
testcase_19 AC 77 ms
75,848 KB
testcase_20 AC 82 ms
76,496 KB
testcase_21 AC 82 ms
76,592 KB
testcase_22 AC 81 ms
76,788 KB
testcase_23 AC 81 ms
76,600 KB
testcase_24 AC 82 ms
76,796 KB
testcase_25 AC 79 ms
76,696 KB
testcase_26 AC 82 ms
76,820 KB
testcase_27 AC 81 ms
76,788 KB
testcase_28 AC 81 ms
76,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ans = 10 ** 18 + 1
D = int(input())

def check(d,k):
    dist = 0
    for i in range(k):
        dist += d
        d //= 2
    return dist <= D

def search(k,d):
    lb = 0
    ub = d + 1
    while ub - lb > 1:
        mid = (ub + lb) // 2
        if check(mid,k):
            lb = mid
        else:
            ub = mid
    return lb

for i in range(1,65):
    d = search(i,D)
    d1 = 0
    d2 = d
    for j in range(i):
        d1 += d2
        d2 //= 2
    if d1 == D:
        ans = min(ans,d)
print(ans)
0