結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
![]() |
提出日時 | 2015-07-25 00:16:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 988 bytes |
コンパイル時間 | 601 ms |
コンパイル使用メモリ | 55,220 KB |
実行使用メモリ | 25,844 KB |
平均クエリ数 | 30.56 |
最終ジャッジ日時 | 2024-07-16 05:05:15 |
合計ジャッジ時間 | 5,423 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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+1; } cnt++; } cout << "! " << left << endl; return 0; }