結果

問題 No.456 Millions of Submits!
ユーザー はむこはむこ
提出日時 2016-11-27 22:47:40
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 3,570 bytes
コンパイル時間 2,274 ms
コンパイル使用メモリ 148,640 KB
実行使用メモリ 8,768 KB
最終ジャッジ日時 2023-09-05 04:25:21
合計ジャッジ時間 12,881 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { if (!v.empty()) { o << '['; copy(v.begin(), v.end(), ostream_iterator<T>(o, ", ")); o << "\b\b]"; } return o; }
using ll = long long; using ld = long double; using vll = vector<ll>; using vi = vector<int>;
typedef pair<ll, ll> P;

static const double EPS = 1e-14;
static const long long INF = 1e18;
#define MAX_N 100005


// 整数二分探索
// f: 単調増加関数. 000111, 111111, 000000を許容する(11110000で探索したい場合は、自分でfを反転すること)
// 閉区間[rl, rr]から単調関数fを満たす最小の数を返す。
// 全て1なら0を返す(定義通り)、全て0ならrr+1を返す(異常検出用)!
//
// xが大で1を返すような関数を作ると思うと間違えない
//
// O(log(range))
ll BinarySearch(ll rl, ll rr, function<bool(ll)> f) { 
    ll lo = rl-1, ro = rr+1;
    while (ro - lo != 1) {
        ll m = (lo + ro) / 2; 
        ((m!=rl-1&&f(m))?ro:lo)=m; 
    }
    return ro;
}
void BinarySearchInteractive(ll rl, ll rr, function<bool(ll)> f) { 
    while (1) {
        cout << "####" << endl;
        ll tmp; cin >> tmp;
        if (rl > tmp) {cout << "Out of range: too small" << endl; continue; }
        if (rr < tmp) {cout << "Out of range: too large" << endl; continue; }
        ll ret = f(tmp); cout << tmp << " : " << ret << endl;
    }
}
void BinarySearchPrint(ll rl, ll rr, function<bool(ll)> f) { 
    for (int i = rl; i <= rr; i++) cout << f(i); cout << endl;
}
void BinarySearchAssert(ll rl, ll rr, function<bool(ll)> f) { 
    bool p = false;
    for (int i = rl; i <= rr; i++) {
        bool t = f(i);
        if (p && !t) cerr << i << ": F NOT MONOTONIC INCREASE" << endl, exit(1);
        p |= t;
    }
}

// 浮動小数点二分探索
ld BinarySearchReal(ld rl, ld rr, function<bool(ld)> f) { 
    rep(i, 200) { ld m = (rl + rr) / 2; f(m)?rr=m:rl=m; }
    return rl;
}
void BinarySearchRealInteractive(ld rl, ld rr, function<bool(ld)> f) { 
    while (1) {
        cout << "####" << endl;
        ld tmp; cin >> tmp;
        if (rl > tmp) {cout << "Out of range: too small" << endl; continue; }
        if (rr < tmp) {cout << "Out of range: too large" << endl; continue; }
        ld ret = f(tmp); cout << tmp << " : " << ret << endl;
    }
}

int main(void) {
    int m; scanf("%d", &m);
    double maxerr = -INF;
    rep(i, m) {
        int a, b; scanf("%d%d", &a, &b);
        double t; scanf("%lf", &t);
//        cout << a << " " << b << " " << t << endl;
        if (!a) {
//            cout << "a=0" << endl;
            printf("%.12f\n", exp(pow(t, 1.0 / b)));
            continue;
        }
        if (!b) {
//            cout << "b=0" << endl;
            printf("%.12f\n", pow(t, 1.0 / a));
            continue;
        }

        auto f = [&](ld x){return pow(x, a) * pow(log(x), b) - t > 0;};
        double n = BinarySearchReal(1e-12, 11, f);
        printf("%.12f\n", n);

//        double err = pow(n, a) * pow(log(n), b) -  t;
//        cout << err << endl;
    }

    return 0;
}
0