結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
![]() |
提出日時 | 2018-12-05 16:01:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 1,725 ms |
コンパイル使用メモリ | 193,636 KB |
最終ジャッジ日時 | 2025-01-06 18:17:30 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} //INSERT ABOVE HERE Int ask(Int x){ cout<<"? "<<x<<endl; Int res; cin>>res; return res; } Int ans(Int x){ cout<<"! "<<x<<endl; exit(0); } signed main(){ Int l=10,r=1e9+100; Int x=ask(50); if(x==0) ans(50); if(x<0){ for(Int i=0;i<50;i++){ Int y=ask(10); if(y<0) ans(10+i); } }else{ Int t=1; for(Int i=0;i<40;i++){ Int m=(l+r)>>1; Int y=ask(m-t++); if(y==0) ans(m); if(y>0) l=m; if(y<0) r=m; } } ans(l); return 0; }