結果

問題 No.1793 実数当てゲーム
ユーザー 👑 hos.lyrichos.lyric
提出日時 2021-12-25 22:33:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,737 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 97,820 KB
実行使用メモリ 24,684 KB
平均クエリ数 2230.56
最終ジャッジ日時 2023-10-22 02:53:44
合計ジャッジ時間 6,579 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
24,684 KB
testcase_01 AC 27 ms
24,684 KB
testcase_02 AC 108 ms
24,684 KB
testcase_03 AC 108 ms
24,684 KB
testcase_04 AC 111 ms
24,684 KB
testcase_05 AC 103 ms
24,684 KB
testcase_06 AC 104 ms
24,684 KB
testcase_07 AC 107 ms
24,684 KB
testcase_08 AC 105 ms
24,684 KB
testcase_09 AC 103 ms
24,684 KB
testcase_10 AC 104 ms
24,684 KB
testcase_11 AC 103 ms
24,684 KB
testcase_12 AC 107 ms
24,684 KB
testcase_13 AC 115 ms
24,684 KB
testcase_14 AC 114 ms
24,684 KB
testcase_15 AC 107 ms
24,684 KB
testcase_16 AC 112 ms
24,684 KB
testcase_17 AC 108 ms
24,684 KB
権限があれば一括ダウンロードができます

ソースコード

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) ? lo : hi) = mid;
    }
    const Double x = get((lo + hi) / 2.0L);
    Answer(x);
  }
  return 0;
}
0