結果

問題 No.1286 Stone Skipping
ユーザー semisagisemisagi
提出日時 2020-11-13 21:38:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 571 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 9,936 KB
最終ジャッジ日時 2023-09-30 16:04:52
合計ジャッジ時間 2,599 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
9,584 KB
testcase_01 AC 32 ms
9,568 KB
testcase_02 AC 44 ms
9,824 KB
testcase_03 AC 33 ms
9,576 KB
testcase_04 AC 34 ms
9,696 KB
testcase_05 AC 33 ms
9,708 KB
testcase_06 AC 34 ms
9,864 KB
testcase_07 AC 34 ms
9,820 KB
testcase_08 AC 37 ms
9,776 KB
testcase_09 AC 35 ms
9,684 KB
testcase_10 AC 35 ms
9,608 KB
testcase_11 AC 36 ms
9,704 KB
testcase_12 AC 37 ms
9,804 KB
testcase_13 AC 47 ms
9,676 KB
testcase_14 AC 46 ms
9,672 KB
testcase_15 AC 46 ms
9,604 KB
testcase_16 AC 47 ms
9,876 KB
testcase_17 AC 46 ms
9,696 KB
testcase_18 AC 31 ms
9,936 KB
testcase_19 AC 31 ms
9,844 KB
testcase_20 AC 47 ms
9,696 KB
testcase_21 AC 47 ms
9,700 KB
testcase_22 AC 36 ms
9,776 KB
testcase_23 AC 39 ms
9,864 KB
testcase_24 AC 47 ms
9,692 KB
testcase_25 AC 46 ms
9,796 KB
testcase_26 AC 46 ms
9,608 KB
testcase_27 AC 46 ms
9,696 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction

def read_int():
    return int(input())

def read_ints():
    return list(map(int, input().split()))

D = read_int()

def f(x):
    y = 0
    while x != 0:
        y += x
        if y == D:
            return True
        x //= 2
    return False

answer = 10 ** 100
for i in range(1, 100):
    # x(1 + 1/2 + 1/4 + 1/8 + ...) ~= D
    x = Fraction(D) / ((1 - Fraction(1, 2) ** i) / (1 - Fraction(1, 2)))
    x = int(x)
    for d in range(-10, 10):
        if x + d >= 1 and f(x + d):
            answer = min(answer, x + d)

print(answer)
0