結果

問題 No.1042 愚直大学
ユーザー tunnytunny
提出日時 2020-05-01 23:10:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 955 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 163,692 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 15:45:53
合計ジャッジ時間 2,549 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 8 ms
4,376 KB
testcase_05 AC 9 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 8 ms
4,384 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 8 ms
4,376 KB
testcase_17 AC 8 ms
4,376 KB
testcase_18 AC 9 ms
4,376 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 8 ms
4,376 KB
testcase_21 AC 8 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {
double func(double x, ll p, ll q) {
  return x*x-q*x*log2(x)-1.0*p;
}

double dfunc(double x, ll q) {
  return 2.0*x-q*(log2(x)+1.0/log(2))-1.0;
}

int main(void) {
  ll p,q;cin>> p >> q;
  double x = 100*q + p;
  int cnt=100000;
  while(abs(func(x,p,q))>0.000001) {
    x = x - func(x,p,q) / dfunc(x,q);
    // printf("%8.8f\n", x);
    cnt--;
    if(cnt<0) {
      break;
    }
  }
  printf("%.8f\n", x);
  return 0;
}
0