結果

問題 No.456 Millions of Submits!
ユーザー koba-e964koba-e964
提出日時 2016-12-08 00:58:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,033 ms / 4,500 ms
コード長 1,097 bytes
コンパイル時間 1,352 ms
コンパイル使用メモリ 43,524 KB
実行使用メモリ 97,948 KB
最終ジャッジ日時 2023-09-05 09:55:52
合計ジャッジ時間 11,595 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
97,836 KB
testcase_01 AC 30 ms
97,932 KB
testcase_02 AC 30 ms
97,932 KB
testcase_03 AC 29 ms
97,948 KB
testcase_04 AC 29 ms
97,928 KB
testcase_05 AC 29 ms
97,868 KB
testcase_06 AC 29 ms
97,816 KB
testcase_07 AC 32 ms
97,872 KB
testcase_08 AC 31 ms
97,868 KB
testcase_09 AC 50 ms
97,912 KB
testcase_10 AC 49 ms
97,868 KB
testcase_11 AC 235 ms
97,912 KB
testcase_12 AC 2,033 ms
97,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;

const int N = 11;
const int B = 100001;
double memo[N][N][B];

/* 0.01 <= z <= 100 */
double lambert_W(double z) {
  double lo = 0.0, hi = 100;
  REP(i, 0, 45) {
    if (hi - lo <= 5e-12) { break; }
    double mid = (lo + hi) / 2;
    if (mid * exp(mid) <= z) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  return lo;
}


double solve(int a, int b, double t) {
  int idx = floor(t * 10000 + 0.5);
  if (memo[a][b][idx] >= 0) {
    return memo[a][b][idx];
  }
  double &ret = memo[a][b][idx];
  if (b == 0) {
    return ret=pow(t, 1.0 / a);
  }
  if (a == 0) {
    return ret=exp(pow(t, 1.0 / b));
  }
  double res = lambert_W(pow(t, 1.0 / b) * a / b); 
  return ret=exp(res * b / a);
}

int main(void){
  int m;
  scanf("%d", &m);
  REP(i, 0, N) {
    REP(j, 0, N) {
      REP(k, 0, B) {
	memo[i][j][k] = -1;
      }
    }
  }
  REP(i, 0, m) {
    int a, b;
    double t;
    scanf("%d%d%lf", &a, &b, &t);
    printf("%.15f\n", solve(a, b, t));
  }
}
0