結果
問題 |
No.246 質問と回答
|
ユーザー |
|
提出日時 | 2015-11-18 16:53:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 921 bytes |
コンパイル時間 | 500 ms |
コンパイル使用メモリ | 57,612 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 31.30 |
最終ジャッジ日時 | 2024-07-16 19:56:57 |
合計ジャッジ時間 | 3,470 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
#include <cstring> #include <algorithm> #include <cstdio> #include <iostream> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; /* ここからが本編 */ /* */ /* 入力開始! */ /* 入力終了! */ /* ll_pow(x,n)はx^nを返すよ! */ ll ll_pow(ll x,ll n) { ll res = 1; while(n > 0) { if(n&1) res = res * x; x = x * x; n >>= 1; } return res; } int main(void) { int i,j,k; int left = 0, right = (int)ll_pow(10,9)+1,mid; while(left < right) { mid = (left+right)/2; int rep; cout << "? " << mid << endl; cin >> rep; if(rep) left = mid; else right = mid-1; if(left + 1 == right) { cout << "? " << right << endl; cin >> rep; if(rep) left = right; } if(mid == (left+right)/2) break; } cout << "! " << left << endl; return 0; }