結果

問題 No.1042 愚直大学
ユーザー d_seid_sei
提出日時 2020-05-01 22:37:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,908 bytes
コンパイル時間 1,091 ms
コンパイル使用メモリ 97,544 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-08-26 15:19:50
合計ジャッジ時間 4,380 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,980 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 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 #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
#define mp make_pair
#define IP pair<int,int>
#define enld endl

bool isOK(lint N, lint P, lint Q) {
	if (N*N>P+Q*N*log2(double(N))) return true;
	else return false;
}

// 汎用的な二分探索のテンプレ
lint binary_search(lint P, lint Q) {
	lint left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	lint right = 1000000000; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる! */
	while (right - left > 1) {
		lint mid = left + (right - left) / 2;

		if (isOK(mid, P,Q)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return left;
}

int main() {
	double P, Q;
	cin >> P >> Q;
	lint now1 = binary_search(P, Q);
	double now = double(now1);
	double d = 0.00001;
	while (1) {
		if (1-Q/now*log2(now)>P/now/now) {
			cout << fixed << setprecision(10) << now - d << endl;
			return 0;
		}
		else {
			now += d;
		}
	}
}
0