結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2021-05-04 17:27:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 69 ms / 2,000 ms |
コード長 | 849 bytes |
コンパイル時間 | 1,861 ms |
コンパイル使用メモリ | 193,444 KB |
最終ジャッジ日時 | 2025-01-21 06:43:58 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
//https://ncode.syosetu.com/n4830bu/253/ #include <bits/stdc++.h> using namespace std; int Time = -1; int ask(int Y) { Time++; cout << "? " << Y << endl; int res; cin >> res; return res; } int main() { int res = ask(100); if (res == 0) cout << "! 100" << endl; else if (res < 0) { while (res != 0) res = ask(1); cout << "! " << Time + 1 << endl; } else { int ok = 1e9 + 10; int ng = 0; while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; res = ask(mid - Time); if (res == 0) { ok = mid; break; } if (res == -1) { ok = mid; } else { ng = mid; } } cout << "! " << ok + 1 << endl; } }