結果

問題 No.1042 愚直大学
ユーザー tunnytunny
提出日時 2020-05-01 23:13:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 650 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 1,285 ms
コンパイル使用メモリ 163,596 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 15:47:59
合計ジャッジ時間 7,971 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 11 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 639 ms
4,376 KB
testcase_05 AC 640 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 633 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 649 ms
4,380 KB
testcase_17 AC 636 ms
4,380 KB
testcase_18 AC 623 ms
4,376 KB
testcase_19 AC 637 ms
4,376 KB
testcase_20 AC 628 ms
4,376 KB
testcase_21 AC 650 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 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)-p;
}

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

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