結果

問題 No.1286 Stone Skipping
ユーザー lloyzlloyz
提出日時 2022-10-10 10:02:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 76,852 KB
最終ジャッジ日時 2023-09-06 10:59:36
合計ジャッジ時間 5,142 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,372 KB
testcase_01 AC 72 ms
71,552 KB
testcase_02 AC 87 ms
76,852 KB
testcase_03 AC 75 ms
75,996 KB
testcase_04 AC 76 ms
76,236 KB
testcase_05 AC 75 ms
76,008 KB
testcase_06 AC 75 ms
76,556 KB
testcase_07 AC 76 ms
76,004 KB
testcase_08 AC 77 ms
76,600 KB
testcase_09 AC 77 ms
76,292 KB
testcase_10 AC 78 ms
76,148 KB
testcase_11 AC 78 ms
76,284 KB
testcase_12 AC 80 ms
76,560 KB
testcase_13 AC 82 ms
76,600 KB
testcase_14 AC 81 ms
76,604 KB
testcase_15 AC 80 ms
76,616 KB
testcase_16 AC 81 ms
76,780 KB
testcase_17 AC 80 ms
76,412 KB
testcase_18 AC 71 ms
71,640 KB
testcase_19 AC 74 ms
71,520 KB
testcase_20 AC 80 ms
76,716 KB
testcase_21 AC 80 ms
76,720 KB
testcase_22 AC 78 ms
76,552 KB
testcase_23 AC 79 ms
76,716 KB
testcase_24 AC 82 ms
76,796 KB
testcase_25 AC 81 ms
76,672 KB
testcase_26 AC 80 ms
76,740 KB
testcase_27 AC 79 ms
76,808 KB
testcase_28 AC 81 ms
76,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import log2

d = int(input())

ans = d
for cnt in range(int(log2(d)) + 2):
    left, right = 0, d
    while right - left > 1:
        mid = (left + right) // 2
        dd = mid
        res = dd
        for _ in range(cnt):
            dd //= 2
            res += dd
        if res >= d:
            right = mid
        else:
            left = mid
    dd = right
    res = dd
    for _ in range(cnt):
        dd //= 2
        res += dd
    if res == d:
        ans = min(ans, right)
print(ans)
0