結果

問題 No.1286 Stone Skipping
ユーザー FromBooskaFromBooska
提出日時 2023-02-15 20:59:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 749 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 80,980 KB
最終ジャッジ日時 2023-09-25 05:06:14
合計ジャッジ時間 6,151 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,316 KB
testcase_01 AC 66 ms
71,328 KB
testcase_02 AC 75 ms
75,364 KB
testcase_03 AC 69 ms
71,484 KB
testcase_04 AC 70 ms
71,256 KB
testcase_05 AC 69 ms
71,240 KB
testcase_06 AC 70 ms
71,572 KB
testcase_07 AC 71 ms
71,324 KB
testcase_08 AC 70 ms
71,392 KB
testcase_09 AC 71 ms
71,300 KB
testcase_10 AC 70 ms
71,100 KB
testcase_11 AC 71 ms
71,252 KB
testcase_12 AC 69 ms
71,364 KB
testcase_13 AC 74 ms
75,440 KB
testcase_14 AC 73 ms
75,496 KB
testcase_15 AC 70 ms
75,328 KB
testcase_16 AC 68 ms
75,280 KB
testcase_17 AC 72 ms
75,484 KB
testcase_18 AC 71 ms
71,388 KB
testcase_19 AC 71 ms
71,236 KB
testcase_20 AC 71 ms
75,568 KB
testcase_21 AC 71 ms
75,316 KB
testcase_22 AC 74 ms
75,408 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

D = int(input())

# むむむ、二分探索と思ったらDにぴったり止まる必要ある
# つまり行き過ぎてはダメなので二分探索ではダメか
# その数が辿り着く数列を考える必要あるか

def max_distance(num):
    dist = 0
    test = False
    while num >= 1:
        dist += num
        num //= 2
        if dist == D:
            test = True
    return dist, test

#for i in range(1, 30):
#    print(i, max_distance(i))

OK = D+1
NG = 0
while OK-NG>1:
    mid = (OK+NG)//2
    if max_distance(mid)[0] >= D:
        OK = mid
    else:
        NG = mid
#print(OK)

candidate = OK
while True:
    if max_distance(candidate)[1] == True:
        print(candidate)
        break
    else:
        candidate += 1
0