結果
| 問題 | No.1042 愚直大学 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-05-01 21:52:23 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 1,700 bytes | 
| コンパイル時間 | 1,859 ms | 
| コンパイル使用メモリ | 165,244 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-25 03:38:02 | 
| 合計ジャッジ時間 | 3,271 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 23 | 
ソースコード
#include <functional>  
#include <algorithm>  
#include <iostream>  
#include <fstream>  
#include <sstream>  
#include <iomanip>  
#include <numeric>  
#include <cstring>  
#include <cassert>  
#include <cstdio>  
#include <string>  
#include <vector>  
#include <bitset>  
#include <queue>  
#include <stack>  
#include <cmath>  
#include <ctime>  
#include <list>  
#include <set>  
#include <map>  
#include <bits/stdc++.h>
using namespace std;
#define PB push_back  
#define MP(A, B) make_pair(A, B)  
#define fi first  
#define se second  
#define gcd(a,b) __gcd(a,b)
#define pi acos(-1.0)
#define pii pair<int,int>
#define ll long long  
#define MAX 1000005  
#define MOD 1000000007  
#define INF 0x3f3f3f3f  
#define EXP 1e-8
#define lowbit(x) (x&-x)  
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
int main() {
    int P, Q;
    cin >> P >> Q;
    double t1, t2;
    double h = 1, l = 1, m;
    t1 = h * h; t2 = P + Q * h * log(h)/log(2);
    while (t1 <= t2) {
        h *= 2;
        t1 = h * h; t2 = P + Q * h * log(h)/log(2);
    }
    // cout << l << ' ' << h << endl;
    while (fabs(h-l) > 1e-5) {
        m = l + (h-l)/2;
        t1 = m * m; t2 = P + Q * m * log(m)/log(2);
        // cout << l << ' ' << h << ' ' << t1 << ' ' << t2 << endl;
        if (t2 >= t1 && fabs(t2-t1) < EXP) break;
        if (t1 <= t2) l = m;
        else h = m;
    }
    m = l + (h-l)/2;
    printf("%.8lf\n", m);
    return 0;
}
            
            
            
        