結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2016-05-05 23:00:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,038 bytes |
コンパイル時間 | 1,615 ms |
コンパイル使用メモリ | 159,540 KB |
実行使用メモリ | 25,952 KB |
平均クエリ数 | 31.86 |
最終ジャッジ日時 | 2024-07-16 10:05:59 |
合計ジャッジ時間 | 9,215 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 35 |
ソースコード
#include <bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; #define FOR(i,a,b) for(int (i)=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define RANGE(vec) (vec).begin(),(vec).end() using namespace std; class LengthOfCandle { public: int ask(int Y){ cout << "? " << Y << endl; int res; cin >> res; return res; } void solve(void) { ll u = 1E+9; ll l = 10; REP(t,100) { // X = Y + t ll mid = (max(l-t,0LL)+max(u-t, 0LL))/2; int res = ask(mid); if ( res == 0 ) { u = mid; break; } if ( res > 0 ) l = mid+t; else u = mid+t; if (u == l) break; } cout<<"! "<<u<<endl; } }; #if 1 int main(int argc, char *argv[]) { ios::sync_with_stdio(false); auto obj = new LengthOfCandle(); obj->solve(); delete obj; return 0; } #endif