結果
問題 | No.253 ロウソクの長さ |
ユーザー |
|
提出日時 | 2021-04-18 03:17:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 666 bytes |
コンパイル時間 | 2,089 ms |
コンパイル使用メモリ | 191,508 KB |
最終ジャッジ日時 | 2025-01-20 21:32:46 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#include <bits/stdc++.h>using namespace std;int query(int y) {cout << "? " << y << endl;cout.flush();int x;cin >> x;return x;}int main() {ios_base::sync_with_stdio(0);cin.tie(0);long long hi = numeric_limits<int>::max();long long lo = -1;int c = query(64);int t = 1;if (c <= 0) {for (;;) {c = query(0);if (c == 0) {cout << "! " << t << endl;return 0;}++t;}}while (hi - lo > 1) {long long mi = (lo + hi) / 2;c = query(mi - t);if (c > 0) lo = mi;else hi = mi;++t;}cout << "! " << hi << endl;cout.flush();return 0;}