結果

問題 No.456 Millions of Submits!
ユーザー PachicobuePachicobue
提出日時 2017-08-14 01:14:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,788 bytes
コンパイル時間 1,636 ms
コンパイル使用メモリ 165,292 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 23:57:39
合計ジャッジ時間 8,887 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// {{{ Templates
#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

// }}}

constexpr long double EPS = 1e-10;

inline long double binary_search(const ll a, const ll b, const long double t)
{
    long double inf = 1.0;
    long double sup = 30000.0;
    while (sup > inf) {
        const long double mid = (inf + sup) / 2;
        const long double c = pow(mid, a) * pow(log(mid), b);
        if (abs(c - t) < EPS) {
            break;
        }
        if (c < t) {
            inf = mid;
        } else {
            sup = mid;
        }
    }
    return inf;
}

inline long double newton(const ll a, const ll b, const long double t)
{
    long double x = 1.0;
    while (true) {
        //        show(x);
        const long double cal = a * x + b * log(x) - log(t);
        if (abs(cal) < EPS) {
            break;
        }
        x -= cal / (a + b / x);
    }
    return exp(x);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m;
    cin >> m;
    for (ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        long double t;
        cin >> t;
        cout << fixed << setprecision(12) << newton(a, b, t) << "\n";
    }
    return 0;
}
0