結果

問題 No.1286 Stone Skipping
ユーザー masashi0217masashi0217
提出日時 2021-03-03 21:15:12
言語 Ruby
(3.2.2)
結果
WA  
実行時間 -
コード長 579 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 11,288 KB
実行使用メモリ 15,372 KB
最終ジャッジ日時 2023-07-26 23:26:21
合計ジャッジ時間 3,799 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 82 ms
15,088 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 83 ms
15,040 KB
testcase_19 AC 82 ms
15,312 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#うまい人の解答見た
d = gets.chomp.to_i
# jump = 100
# ans = 10 ** 19

def f(x,limt)
    len = 0
    cnt = 0
    while x > 0 && cnt < limt
        len += x
        x = x/ 2
        cnt += 1
        #x = x / 2
        #jump_count += 1
    end
    return len
end



ans = d
1.upto(100) do |i|
    left = 0
    right = 10 ** 19
    while (left - right) > 1
        mid = (left + right) / 2
        if d <= f(mid,i)
            right = mid
        else
            left = mid
        end
    end
    if f(right,i) == d && ans > right
        ans = right
    end
end
puts ans
0