結果

問題 No.456 Millions of Submits!
ユーザー rickythetarickytheta
提出日時 2016-12-08 15:30:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 786 ms / 4,500 ms
コード長 2,996 bytes
コンパイル時間 2,430 ms
コンパイル使用メモリ 145,932 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-05 15:59:57
合計ジャッジ時間 9,390 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define __GET_REP_MACRO(_1,_2,_3,NAME,...) NAME
#define __REP0(i,n) for(_loop_int i=0;i<(n);++i)
#define __REP1(i,a,b) for(_loop_int i=(a);i<(b);++i)
#define __REPR0(i,n) for(_loop_int i=(n)-1;i>=0;--i)
#define __REPR1(i,a,b) for(_loop_int i=(b)-1;i>=(a);--i)
#define REP(...) __GET_REP_MACRO(__VA_ARGS__,__REP1,__REP0)(__VA_ARGS__)
#define REPR(...) __GET_REP_MACRO(__VA_ARGS__,__REPR1,__REPR0)(__VA_ARGS__)

#ifdef BURI
#define __DEBUG0() "Hello"
#define __DEBUG1(x) #x"("<<(x)<<")"
#define __DEBUG2(x,...) #x"("<<(x)<<"), " __DEBUG1(__VA_ARGS__)
#define __DEBUG3(x,...) #x"("<<(x)<<"), " __DEBUG2(__VA_ARGS__)
#define __DEBUG4(x,...) #x"("<<(x)<<"), " __DEBUG3(__VA_ARGS__)
#define __DEBUG5(x,...) #x"("<<(x)<<"), " __DEBUG4(__VA_ARGS__)
#define __GET_DEBUG_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define __DEBUG(...) __GET_DEBUG_MACRO(__VA_ARGS__,__DEBUG5,__DEBUG4,__DEBUG3, \
__DEBUG2,__DEBUG1,__DEBUG0)(__VA_ARGS__)
#define DEBUG(...) cerr<<__DEBUG(__VA_ARGS__)<<endl
#else
#define DEBUG(...)
#endif

#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

#define __my_getchar getchar_unlocked
inline void getll(ll &x){
  bool neg=false;x=0;char c;
  while((c=__my_getchar())!='-'&&(c<'0'||c>'9'));
  if(c=='-') neg=true; else x=c-'0';
  while('0'<=(c=__my_getchar())&&c<='9')x=10*x+(c-'0');
  if(neg)x=-x;
}
inline void read(ll &x){getll(x);}
inline void read(int &x){ll y;getll(y);x=y;}
inline void read(float &x){scanf("%f",&x);}
inline void read(double &x){scanf("%lf",&x);}
inline void read(long double &x){scanf("%Lf",&x);}
inline void read(char *s){scanf("%s",s);}
inline void read(string &s){int len=s.size();char *buf=(char*)malloc(len*sizeof(char));scanf("%s",buf);s=string(buf);free(buf);}
inline void read(char &c){char *buf=(char*)malloc(5*sizeof(char));scanf("%s",buf);c=buf[0];free(buf);}
inline void read(){}
template<typename S,typename ...T>
inline void read(S& first, T&... rest){
  read(first);
  read(rest...);
}

inline void lambert(double &w, double &z){
  // w exp(w) = tt
  // double ew = exp(w);
  // double po = w * ew;
  // double f0 = po - z;
  // double f1 = po + ew;
  // double f2 = f1 + ew;
  // w -= (f0 * f1)/(f1 * f1 - f2 * f0 * 0.5);
  double ex = exp(w);
  w -= (2.0*(w+1.0)*(ex*w-z)) / (z*(w+2.0)+ex*(w*(w+2.0)+2.0));
  // w -= 2.0 + 2.0*z / (w * exp(w));
  DEBUG(w);
}

int main(){
  // x = exp(b/a * W(a/b * pow(t,1/b)))
  int m;
  int a,b;
  double t;
  read(m);
  while(m--){
    read(a,b,t);
    if(b==0){
      printf("%.9f\n",pow(t,1.0/a));
    }else if(a==0){
      printf("%.9f\n",exp(pow(t,1.0/b)));
    }else{
      double binv = 1.0/b;
      double a_b = binv*a;
      double tt = a_b * pow(t,binv);
      // lambert w function iteration
      double w = max(log(tt),0.1);
      lambert(w,tt);
      lambert(w,tt);
      lambert(w,tt);
      printf("%.9f\n",exp(w / a_b));
    }
  }
  return 0;
}
0