結果

問題 No.1286 Stone Skipping
ユーザー masashi0217masashi0217
提出日時 2021-03-03 21:15:33
言語 Ruby
(3.3.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-04-14 12:56:38
合計ジャッジ時間 4,287 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
12,416 KB
testcase_01 AC 100 ms
12,288 KB
testcase_02 AC 104 ms
12,544 KB
testcase_03 AC 103 ms
12,544 KB
testcase_04 AC 103 ms
12,544 KB
testcase_05 AC 102 ms
12,544 KB
testcase_06 AC 101 ms
12,416 KB
testcase_07 AC 102 ms
12,544 KB
testcase_08 AC 102 ms
12,288 KB
testcase_09 AC 102 ms
12,288 KB
testcase_10 AC 100 ms
12,288 KB
testcase_11 AC 103 ms
12,416 KB
testcase_12 AC 103 ms
12,288 KB
testcase_13 AC 106 ms
12,416 KB
testcase_14 AC 108 ms
12,416 KB
testcase_15 AC 108 ms
12,544 KB
testcase_16 AC 107 ms
12,288 KB
testcase_17 AC 106 ms
12,288 KB
testcase_18 AC 99 ms
12,416 KB
testcase_19 AC 100 ms
12,288 KB
testcase_20 AC 110 ms
12,544 KB
testcase_21 AC 107 ms
12,288 KB
testcase_22 AC 102 ms
12,416 KB
testcase_23 AC 102 ms
12,416 KB
testcase_24 AC 108 ms
12,416 KB
testcase_25 AC 109 ms
12,416 KB
testcase_26 AC 108 ms
12,288 KB
testcase_27 AC 107 ms
12,288 KB
testcase_28 AC 107 ms
12,288 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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).abs > 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