結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
![]() |
提出日時 | 2019-12-05 09:54:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,553 bytes |
コンパイル時間 | 1,472 ms |
コンパイル使用メモリ | 127,972 KB |
最終ジャッジ日時 | 2025-01-08 08:40:01 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 WA * 2 |
ソースコード
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<map> #include<set> #include<cstdio> #include<cmath> #include<numeric> #include<queue> #include<stack> #include<cstring> #include<limits> #include<functional> #include<unordered_set> #include<iomanip> #include<cassert> #include<regex> #define rep(i,a) for(int i=(int)0;i<(int)a;++i) #define pb push_back #define eb emplace_back using ll=long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 50; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } using namespace std; int C(int mid){ cout<<"? "<<mid<<endl; int res; cin>>res; return res; } void solve(){ int l=10,r=100; int cnt=0; int x,y=10; rep(i,50){ int mid=(l+r)/2; if(mid-cnt>=0)x=C(mid-cnt); else break; if(x==-1)r=mid; else if(x==1)l=mid; else { cout<<"! "<<mid<<endl; return ; } ++cnt; } l=10,r=1e9; rep(i,50){ int mid=(l+r)/2; if(mid-cnt>=0)x=C(mid-cnt); //else break; if(x==-1)r=mid; else if(x==1)l=mid; else { cout<<"! "<<mid<<endl; return ; } ++cnt; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout<<fixed<<setprecision(15); solve(); return 0; }