結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
![]() |
提出日時 | 2015-07-25 00:09:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 985 bytes |
コンパイル時間 | 420 ms |
コンパイル使用メモリ | 55,008 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 30.75 |
最終ジャッジ日時 | 2024-07-16 05:04:10 |
合計ジャッジ時間 | 5,306 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 21 |
ソースコード
#include <iostream> using namespace std; int main(){ int left = 0; int right = 1000000001; int cnt = 0; int ans; cout << "? 100" << endl; cout.flush(); cin >> ans; if(ans == -1){ for(int i = 0; i < 99; i++){ cout << "? 9" << endl; cout.flush(); cin >> ans; if(ans == 0){ cout << "! " << 10 + i << endl; break; } } return 0; }else if(ans == 0){ cout << "! 100" << endl; return 0; } while(left + 1 < right){ int middle = (left + right) / 2; cout << "? " << max(0, middle - cnt) << endl; cout.flush(); int ans; cin >> ans; if(ans == -1){ right = middle; }else if(ans == 0){ left = middle; break; }else{ left = middle; } cnt++; } cout << "! " << left << endl; return 0; }