結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
![]() |
提出日時 | 2015-07-24 22:53:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 1,118 bytes |
コンパイル時間 | 535 ms |
コンパイル使用メモリ | 72,184 KB |
実行使用メモリ | 25,252 KB |
平均クエリ数 | 29.28 |
最終ジャッジ日時 | 2024-07-16 20:48:39 |
合計ジャッジ時間 | 3,238 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#include <cstdio> #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include <algorithm> #include <vector> #include <queue> #include <stack> #include <map> #include <set> #include <cstring> typedef long long ll; using namespace std; #define mod 1000003 #define INF 1000000000 #define LLINF 2000000000000000000LL #define SIZE 100 int ask(int Y){ cout << "? " << Y << endl; int res; cin >> res; return res; } void ans(int Y){ cout << "! " << Y << endl; return; } int main(){ int l=10,r=1000000000,mid; if(ask(35)==-1){ for(int i=1;;i++){ if(ask(0)==0){ ans(i); return 0; } } } for(int i=1;;i++){ if(l==r){ ans(l); return 0; } mid = (l+r)/2; int q = ask(mid-i); if(q==1){ l = mid+1; }else if(q==-1){ r = mid; }else if(q==0){ ans(mid); return 0; } } return 0; }