結果

問題 No.1793 実数当てゲーム
ユーザー assy1028assy1028
提出日時 2021-12-23 13:46:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 2,357 bytes
コンパイル時間 1,138 ms
コンパイル使用メモリ 112,024 KB
実行使用メモリ 24,660 KB
平均クエリ数 2230.56
最終ジャッジ日時 2023-10-17 14:08:39
合計ジャッジ時間 4,281 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
24,660 KB
testcase_01 AC 27 ms
24,660 KB
testcase_02 AC 111 ms
24,660 KB
testcase_03 AC 109 ms
24,660 KB
testcase_04 AC 111 ms
24,660 KB
testcase_05 AC 100 ms
24,660 KB
testcase_06 AC 99 ms
24,660 KB
testcase_07 AC 102 ms
24,660 KB
testcase_08 AC 104 ms
24,660 KB
testcase_09 AC 103 ms
24,660 KB
testcase_10 AC 100 ms
24,660 KB
testcase_11 AC 102 ms
24,660 KB
testcase_12 AC 109 ms
24,660 KB
testcase_13 AC 124 ms
24,660 KB
testcase_14 AC 123 ms
24,660 KB
testcase_15 AC 110 ms
24,660 KB
testcase_16 AC 123 ms
24,660 KB
testcase_17 AC 109 ms
24,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
#include <stdio.h>
#include <bitset>
#include <cassert>

using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef tuple<int, int, vector<int>> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

double get_elapsed_time(struct timeval *begin, struct timeval *end) {
    return (end->tv_sec - begin->tv_sec) * 1000
	+ (end->tv_usec - begin->tv_usec) / 1000.0;
}

unsigned long xor128(void) {
    static unsigned long x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned long t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}

// [0, k)
int rand(int k) {
    return xor128() % k;
}

random_device seed_gen;
ranlux24 engine(seed_gen());

double error(const double x, const double y) {
    return min(abs(x - y) / x, abs(x - y));
}

void solve() {
    double lb = 1e-6, ub = 1.222e75;
    int i;
    string s;
    for (i = 0; i < 24; i++) {
        const double m = sqrt(lb * ub);
        cout << "? " << m << endl; cout.flush();
        cin >> s;
        if (s == "Yes") {
            lb = m;
        } else {
            ub = m;
        }
    }

    const double y = (lb + ub) / 2;
    cout << "! " << y << endl; cout.flush();
}

void input() {

}

int main(int argc, char *argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        //input();
        solve();
    }
}
0