結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
![]() |
提出日時 | 2018-10-27 01:36:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,041 bytes |
コンパイル時間 | 2,049 ms |
コンパイル使用メモリ | 192,920 KB |
最終ジャッジ日時 | 2025-01-06 14:50:33 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 6 |
ソースコード
#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 - 5) { int m = (l + r) / 2; ask(m); cin >> res; if (res == 1) { l = m; } else if (res == 0) { ans(res + cnt - 1); } else { r = m; } l--; } while (1) { ask(l); cin >> res; if (res == 0) { ans(l + cnt - 1); } } }