結果

問題 No.1286 Stone Skipping
ユーザー ygd.ygd.
提出日時 2020-11-13 21:50:26
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 722 bytes
コンパイル時間 968 ms
コンパイル使用メモリ 86,804 KB
実行使用メモリ 82,212 KB
最終ジャッジ日時 2023-09-30 02:46:29
合計ジャッジ時間 6,353 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
82,212 KB
testcase_01 AC 72 ms
75,132 KB
testcase_02 AC 71 ms
75,228 KB
testcase_03 AC 73 ms
75,120 KB
testcase_04 AC 74 ms
75,084 KB
testcase_05 AC 72 ms
75,140 KB
testcase_06 AC 73 ms
75,300 KB
testcase_07 AC 72 ms
75,136 KB
testcase_08 AC 73 ms
75,260 KB
testcase_09 AC 73 ms
75,132 KB
testcase_10 AC 73 ms
75,264 KB
testcase_11 AC 74 ms
75,136 KB
testcase_12 AC 74 ms
74,984 KB
testcase_13 AC 72 ms
75,044 KB
testcase_14 AC 72 ms
74,984 KB
testcase_15 AC 72 ms
75,188 KB
testcase_16 AC 72 ms
75,352 KB
testcase_17 AC 73 ms
75,116 KB
testcase_18 AC 71 ms
75,088 KB
testcase_19 AC 71 ms
75,404 KB
testcase_20 AC 71 ms
75,232 KB
testcase_21 AC 73 ms
75,060 KB
testcase_22 AC 75 ms
75,376 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

D = int(input())
ok = pow(10,18)*2
ng = 0

def check(x):
    ret = x
    while x > 0:
        x = x//2
        ret += x
    return ret
cnt = 0
while abs(ok-ng) > 1: #and cnt < 100:
    mid = (ok+ng)//2
    #print(ok,mid,ng)
    if check(mid) >= D:
        ok = mid
    else:
        ng = mid
    cnt += 1
ans = ok
#print(ans)

def verify(x,y):
    ret = x
    while x > 0:
        if ret == y:
            return True
        else:
            x = x//2
            ret += x
    if ret == y:
        return True
    else:
        return False
a = ans + 0
b = ans - 0

while True:
    if verify(a,D):
        print(a)
        break
    elif verify(b,D):
        print(b)
        break
    else:
        a += 1
        b -= 1
0