結果

問題 No.1793 実数当てゲーム
ユーザー 👑 hos.lyrichos.lyric
提出日時 2021-12-22 00:56:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,733 bytes
コンパイル時間 792 ms
コンパイル使用メモリ 94,372 KB
実行使用メモリ 24,408 KB
平均クエリ数 1.00
最終ジャッジ日時 2023-10-13 20:18:04
合計ジャッジ時間 4,711 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }

using Double = long double;

constexpr int N = 24;
constexpr Double EPS = 1e-10L;
constexpr Double L = 12.22e+74L;

bool Ask(Double y) {
  printf("%.20Lf\n", y);
  fflush(stdout);
  char buf[10];
  scanf("%s", buf);
  if (!strcmp(buf, "-1")) {
    assert(false);
  }
  return !strcmp(buf, "Yes");
}
void Answer(Double x) {
  printf("%.20Lf\n", x);
  fflush(stdout);
}

Double get(Double t) {
  return (t < 0.0L) ? (1.0L + EPS * t) : exp(t * log1p(EPS));
}

int main() {
  int numCases;
  scanf("%d", &numCases);
  for (; numCases--; ) {
    Double lo = -1.0L / EPS, hi = log(L) / log1p(EPS);
    for (int i = 0; i < N; ++i) {
      const Double mid = (lo + hi) / 2.0L;
      const Double y = get(mid);
      (Ask(y) ? hi : lo) = mid;
    }
    const Double x = get((lo + hi) / 2.0L);
    Answer(x);
  }
  return 0;
}
0