結果
| 問題 |
No.253 ロウソクの長さ
|
| コンテスト | |
| ユーザー |
walkre
|
| 提出日時 | 2015-08-01 16:48:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 1,266 bytes |
| コンパイル時間 | 1,357 ms |
| コンパイル使用メモリ | 158,900 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 29.28 |
| 最終ジャッジ日時 | 2024-07-16 21:05:45 |
| 合計ジャッジ時間 | 3,988 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif
typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;
const int INF=1<<30;
const long long int LLNF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
void Solve(){
{
int res;
cout << "? " << 50 << endl;
cin >> res;
if(res==-1){
int k=1;
while(true){
cout << "? " << 0 << endl;
cin >> res;
if(res==0){
cout << "! " << k << endl;
return;
}
++k;
}
}
}
int lb=10,ub=1000000001,k=1;
while(true){
int mid=(lb+ub)/2,res;
cout << "? " << mid << endl;
cin >> res;
if(res==0){
cout << "! " << mid+k << endl;
break;
}else if(res==-1) ub=mid;
else lb=mid;
--lb;
--ub;
if(lb<0) lb=0;
if(ub<0) ub=0;
++k;
}
}
int main(){
Solve();
return 0;
}
walkre