結果

問題 No.1042 愚直大学
ユーザー tarattata1tarattata1
提出日時 2020-05-01 21:46:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,445 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 77,944 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-26 09:00:39
合計ジャッジ時間 3,266 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
4,376 KB
testcase_01 AC 52 ms
4,380 KB
testcase_02 AC 53 ms
4,376 KB
testcase_03 AC 51 ms
4,384 KB
testcase_04 AC 50 ms
4,376 KB
testcase_05 AC 51 ms
4,376 KB
testcase_06 AC 51 ms
4,376 KB
testcase_07 AC 51 ms
4,376 KB
testcase_08 AC 52 ms
4,376 KB
testcase_09 AC 51 ms
4,384 KB
testcase_10 AC 53 ms
4,380 KB
testcase_11 AC 51 ms
4,380 KB
testcase_12 AC 51 ms
4,376 KB
testcase_13 AC 52 ms
4,504 KB
testcase_14 AC 51 ms
4,376 KB
testcase_15 AC 52 ms
4,376 KB
testcase_16 AC 51 ms
4,380 KB
testcase_17 AC 51 ms
4,380 KB
testcase_18 AC 51 ms
4,380 KB
testcase_19 AC 52 ms
4,384 KB
testcase_20 AC 51 ms
4,380 KB
testcase_21 AC 53 ms
4,384 KB
testcase_22 AC 51 ms
4,376 KB
testcase_23 AC 51 ms
4,380 KB
testcase_24 AC 52 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int p, q;

double func(double x)
{
    double ans = (double)p + (double)q*x*log(x) / log(2) - x * x;
    return ans;
}


void solve()
{
    scanf("%d%d", &p, &q);

    long double l = 1, r = 1000000000000000000;

    //printf("%.10lf\n", func(l));
    //printf("%.10lf\n", func(r));
    //printf("%.10lf\n", func((l+r)/2));
    int i;
    for (i = 0; i < 1000000; i++) {
        long double m = (l + r) / 2;
        if (func(m) > 0) {
            l = m;
        }
        else {
            r = m;
        }
    }
    printf("%.10Lf\n", r);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}

0