結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2018-10-27 01:47:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 1,053 bytes |
コンパイル時間 | 2,088 ms |
コンパイル使用メモリ | 191,556 KB |
最終ジャッジ日時 | 2025-01-06 14:51:35 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; using vi = vector<i64>; using vvi = vector<vi>; int cnt; void ask(int x) { cout << "? " << x << endl; cnt++; } void ans(int x) { cout << "! " << x << endl; exit(0); } int res; int main() { bool ge100; ask(100); cin >> res; if (res == 0) { ans(100); } else if (res == 1) { ge100 = true; } else { ge100 = false; } if (!ge100) { while (1) { ask(8); cin >> res; if (res == 0) { ans(8 + cnt - 1); } } } int l = 99, r = 1e9 + 1; while (l < r - 10) { int m = (l + r) / 2; ask(m); cin >> res; if (res == 1) { l = m; } else if (res == 0) { ans(m + cnt - 1); } else { r = m; } l--; } l -= 10; while (1) { ask(l); cin >> res; if (res == 0) { ans(l + cnt - 1); } } }