結果

問題 No.456 Millions of Submits!
ユーザー yosupot
提出日時 2016-12-07 23:18:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1,748 ms / 4,500 ms
コード長 1,572 bytes
コンパイル時間 928 ms
コンパイル使用メモリ 96,536 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-23 03:49:39
合計ジャッジ時間 8,241 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:62:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   62 |     scanf("%d", &m);
      |     ~~~~~^~~~~~~~~~
main.cpp:65:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   65 |         scanf("%d %d %lf", &a, &b, &t);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

//const double E = exp(double(1));
const double E = 2.7182818284590452353602874713526624977572;

double get(int a, int b, double x) {
    double ans = 1;
    for (int i = 0; i < a; i++) {
        ans *= x;
    }
    double lx = log(x);
    for (int i = 0; i < b; i++) {
        ans *= lx;
    }
//    return pow(x, a)*pow(log(x), b);
    return ans;
}
double calc(int a, int b, double t) {
    if (a == 0) {
        return pow(E, pow(t, 1.0/b));
    }
    if (b == 0) {
        return pow(t, 1.0/a);
    }
    double l = 1, r = 101;
    for (int i = 0; i < 40; i++) {
        double md = (l+r)/2;
        double x = get(a, b, md);
        if (x < t) {
            l = md;
        } else {
            r = md;
        }
    }
    return l;
}

int main() {
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; i++) {
        int a, b; double t;
        scanf("%d %d %lf", &a, &b, &t);
        double x = calc(a, b, t);
        if (x < 1e12) {
            printf("%.12lf\n", x);
        } else {
            printf("%lf\n", x);
        }
    }
    return 0;
}
0