結果

問題 No.1042 愚直大学
ユーザー ks2mks2m
提出日時 2020-05-01 21:47:26
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 718 bytes
コンパイル時間 2,153 ms
コンパイル使用メモリ 72,528 KB
実行使用メモリ 73,904 KB
最終ジャッジ日時 2023-08-26 09:03:42
合計ジャッジ時間 6,445 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
56,316 KB
testcase_01 AC 133 ms
56,400 KB
testcase_02 AC 134 ms
56,064 KB
testcase_03 AC 130 ms
56,392 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int q = sc.nextInt();
		sc.close();

		double ok = 1;
		double ng = 1e18;
		while (Math.abs(ok - ng) > 1e-6) {
			double mid = (ok + ng) / 2;
			if (calc(mid, q) <= p) {
				ok = mid;
			} else {
				ng = mid;
			}
		}
		System.out.println(ok);
	}

	static double calc(double mid, int q) {
		BigDecimal bn = BigDecimal.valueOf(mid);
		BigDecimal bq = BigDecimal.valueOf(q);
		BigDecimal bln = BigDecimal.valueOf(Math.log10(mid) / Math.log10(2));
		return bn.multiply(bn.subtract(bq.multiply(bln))).doubleValue();
	}
}
0