結果

問題 No.1286 Stone Skipping
ユーザー tentententen
提出日時 2021-02-03 11:23:42
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 727 bytes
コンパイル時間 3,744 ms
コンパイル使用メモリ 70,852 KB
実行使用メモリ 57,820 KB
最終ジャッジ日時 2023-09-12 11:48:20
合計ジャッジ時間 9,366 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,988 KB
testcase_01 AC 124 ms
56,036 KB
testcase_02 AC 125 ms
55,844 KB
testcase_03 AC 124 ms
55,984 KB
testcase_04 AC 124 ms
55,712 KB
testcase_05 WA -
testcase_06 AC 124 ms
55,740 KB
testcase_07 AC 123 ms
55,980 KB
testcase_08 AC 124 ms
54,340 KB
testcase_09 AC 124 ms
55,820 KB
testcase_10 AC 123 ms
55,840 KB
testcase_11 AC 125 ms
55,920 KB
testcase_12 AC 123 ms
55,892 KB
testcase_13 AC 122 ms
56,012 KB
testcase_14 AC 125 ms
55,844 KB
testcase_15 WA -
testcase_16 AC 124 ms
55,580 KB
testcase_17 AC 123 ms
55,900 KB
testcase_18 AC 123 ms
55,860 KB
testcase_19 AC 124 ms
56,260 KB
testcase_20 AC 122 ms
55,956 KB
testcase_21 AC 122 ms
56,472 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 121 ms
56,104 KB
testcase_26 AC 121 ms
55,832 KB
testcase_27 AC 120 ms
55,488 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long d = sc.nextLong();
        long min = d;
        long left = 0;
        long right = d;
        while (right - left > 1) {
            long m = (left + right) / 2;
            long x = 1;
            long sum = 0;
            while (x <= m && sum <= d) {
                sum += m / x;
                if (sum == d) {
                    min = Math.min(min, m);
                }
                x <<= 1;
            }
            if (sum < d) {
                left = m;
            } else {
                right = m;
            }
        }
        System.out.println(min);
    }
}
0