結果

問題 No.1286 Stone Skipping
ユーザー tentententen
提出日時 2020-11-25 21:00:37
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 693 bytes
コンパイル時間 2,358 ms
コンパイル使用メモリ 71,800 KB
実行使用メモリ 56,172 KB
最終ジャッジ日時 2023-10-01 01:53:46
合計ジャッジ時間 11,022 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,112 KB
testcase_01 AC 120 ms
55,500 KB
testcase_02 AC 124 ms
55,712 KB
testcase_03 AC 120 ms
55,828 KB
testcase_04 AC 119 ms
55,744 KB
testcase_05 AC 120 ms
55,820 KB
testcase_06 AC 120 ms
55,704 KB
testcase_07 AC 118 ms
55,736 KB
testcase_08 AC 119 ms
55,688 KB
testcase_09 AC 119 ms
55,832 KB
testcase_10 AC 121 ms
54,024 KB
testcase_11 AC 124 ms
55,548 KB
testcase_12 AC 121 ms
55,572 KB
testcase_13 AC 119 ms
55,648 KB
testcase_14 AC 119 ms
55,812 KB
testcase_15 AC 123 ms
55,568 KB
testcase_16 AC 125 ms
55,808 KB
testcase_17 AC 118 ms
55,760 KB
testcase_18 AC 121 ms
55,624 KB
testcase_19 AC 118 ms
55,880 KB
testcase_20 AC 119 ms
55,676 KB
testcase_21 AC 118 ms
56,172 KB
testcase_22 AC 119 ms
55,764 KB
testcase_23 AC 519 ms
55,740 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

0