結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
![]() |
提出日時 | 2015-08-17 23:05:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 530 bytes |
コンパイル時間 | 1,650 ms |
コンパイル使用メモリ | 160,804 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 8.72 |
最終ジャッジ日時 | 2024-07-16 05:40:39 |
合計ジャッジ時間 | 8,925 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 36 |
ソースコード
#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() { int cnt = 0; auto f = [&](int m){ cout << "? " << m - cnt << endl; ++cnt; int res; cin >> res; return res > 0; }; cout << "! " << binarySearch(f, 10, f(100) ? 1e9 + 1 : 101) << endl; }