結果

問題 No.1042 愚直大学
ユーザー ks2mks2m
提出日時 2020-05-01 21:46:07
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 72,076 KB
実行使用メモリ 56,624 KB
最終ジャッジ日時 2023-08-26 08:59:26
合計ジャッジ時間 5,916 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 126 ms
56,040 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 122 ms
56,548 KB
testcase_05 AC 127 ms
56,580 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 128 ms
55,908 KB
testcase_12 AC 126 ms
56,384 KB
testcase_13 AC 126 ms
56,052 KB
testcase_14 AC 121 ms
56,020 KB
testcase_15 AC 120 ms
56,356 KB
testcase_16 AC 124 ms
56,232 KB
testcase_17 AC 125 ms
56,548 KB
testcase_18 AC 124 ms
56,296 KB
testcase_19 AC 121 ms
56,360 KB
testcase_20 AC 121 ms
56,216 KB
testcase_21 AC 119 ms
56,136 KB
testcase_22 AC 121 ms
56,116 KB
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

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) > 1) {
			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