結果

問題 No.1286 Stone Skipping
ユーザー tentententen
提出日時 2020-11-25 20:53:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 644 bytes
コンパイル時間 3,307 ms
コンパイル使用メモリ 71,824 KB
実行使用メモリ 57,552 KB
最終ジャッジ日時 2023-10-01 01:53:15
合計ジャッジ時間 8,355 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,668 KB
testcase_01 AC 128 ms
55,632 KB
testcase_02 AC 126 ms
55,916 KB
testcase_03 AC 125 ms
55,480 KB
testcase_04 AC 126 ms
55,764 KB
testcase_05 WA -
testcase_06 AC 125 ms
56,048 KB
testcase_07 AC 136 ms
55,620 KB
testcase_08 AC 126 ms
55,756 KB
testcase_09 AC 125 ms
55,528 KB
testcase_10 AC 123 ms
55,696 KB
testcase_11 AC 125 ms
55,448 KB
testcase_12 AC 124 ms
56,008 KB
testcase_13 AC 126 ms
55,768 KB
testcase_14 AC 129 ms
55,444 KB
testcase_15 WA -
testcase_16 AC 126 ms
55,784 KB
testcase_17 AC 125 ms
56,072 KB
testcase_18 AC 125 ms
55,792 KB
testcase_19 AC 122 ms
55,676 KB
testcase_20 AC 133 ms
55,544 KB
testcase_21 AC 124 ms
55,300 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 123 ms
55,596 KB
testcase_26 AC 123 ms
53,660 KB
testcase_27 AC 125 ms
55,668 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 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;
		    }
		}
		long sum = 0;
		long x = right;
		while (x > 0 && sum < d) {
		    sum += x;
		    x /= 2;
		}
		if (sum == d) {
		    System.out.println(right);
		} else {
		    System.out.println(d);
		}
   }
}

0