結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2022-03-22 22:31:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 649 bytes |
コンパイル時間 | 4,005 ms |
コンパイル使用メモリ | 249,532 KB |
最終ジャッジ日時 | 2025-01-28 11:01:35 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) #define Inf 1000000001 int cnt = 0; void answer(int n){ cout<<"! "<<n<<endl; exit(0); } //is greater n? bool query(int n){ cout<<"? "<<n<<endl; int r; cin>>r; if(r==0){ answer(n+cnt); } cnt++; if(r==1)return true; return false; } int main(){ bool f = query(50); if(f){ int ok = 50,ng = 1000000005; while(ng-ok>1){ int mid = (ok+ng)/2; if(query(mid-cnt))ok = mid; else ng = mid; } } else{ while(true)query(0); } return 0; }