結果

問題 No.456 Millions of Submits!
ユーザー r_dream0r_dream0
提出日時 2017-02-21 21:48:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2,853 ms / 4,500 ms
コード長 837 bytes
コンパイル時間 911 ms
コンパイル使用メモリ 68,204 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 23:09:21
合計ジャッジ時間 11,690 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

double pow(double t, int a) {
  double r = 1;
  for(;a > 0;a >>= 1) {
    if(a & 1) r *= t;
    t *= t;
  }
  return r;
}
int a, b;
double t;
double f(double x, double logx) {
  return pow(x, a) * pow(logx, b) - t;
}

double fn(double x, double logx) {
  return pow(x, a - 1)  * pow(logx, b - 1) * (a * logx + b);
}
int main() {
  int T;
  scanf("%d", &T);
  while(T--) {
    scanf("%d %d %lf", &a, &b, &t);
    if(a == 0) {
      printf("%.11f\n", exp(pow(t, 1.0 / b)));
    }else if(b == 0) {
      printf("%.11f\n", pow(t, 1.0 / a));
    }else{
      double x = 2; // 初期値
      for(int i = 0; i < 50; i++) {
        double logx = log(x);
        double nx = x - f(x, logx) / fn(x, logx);
        x = nx;
      }
      printf("%.11f\n", x);
    }
  }
}
0