結果
問題 |
No.246 質問と回答
|
ユーザー |
![]() |
提出日時 | 2015-08-16 08:32:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 477 bytes |
コンパイル時間 | 1,674 ms |
コンパイル使用メモリ | 160,760 KB |
実行使用メモリ | 25,544 KB |
平均クエリ数 | 30.00 |
最終ジャッジ日時 | 2024-07-16 07:53:56 |
合計ジャッジ時間 | 5,457 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; long long binarySearch(function<bool(long long)> func, long long include, long long exclude) { while (abs(exclude - include) > 1) { long long middle = (include + exclude) / 2; (func(middle) ? include : exclude) = middle; } return include; } int main() { auto f = [](int m){ cout << "? " << m << endl; int res; cin >> res; return res; }; cout << "! " << binarySearch(f, 1, 1e9 + 1) << endl; }