結果

問題 No.246 質問と回答
コンテスト
ユーザー knk
提出日時 2017-09-18 14:02:52
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 521 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 384 ms
コンパイル使用メモリ 79,340 KB
実行使用メモリ 28,708 KB
平均クエリ数 30.87
最終ジャッジ日時 2026-03-31 09:33:03
合計ジャッジ時間 7,893 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <iomanip>

typedef long long ll;

int main(void)
{
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(8);
  ll bottom = 0, top = 1000000001;
  ll piv = (bottom + top) / 2;
  while (top - bottom > 1) {
    std::cout << "? " << piv << std::endl; std::cout.flush();
    int ans;
    std::cin >> ans;
    if (ans == 1) bottom = piv;
    else top = piv;
    piv = (top + bottom) / 2;
  }
  std::cout << "! " << bottom << std::endl;
  return 0;
}
0