結果
問題 | No.246 質問と回答 |
ユーザー |
![]() |
提出日時 | 2015-09-10 17:59:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 798 bytes |
コンパイル時間 | 426 ms |
コンパイル使用メモリ | 61,464 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 30.87 |
最終ジャッジ日時 | 2024-07-16 19:55:02 |
合計ジャッジ時間 | 3,409 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:38:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d", &x); | ~~~~~^~~~~~~~~~
ソースコード
// BCC #include <cstdio> #include <algorithm> #include <iostream> #include <utility> #include <vector> #include <queue> // GCC // #include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; i--) #define each(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define chmin(a, b) a = min(a, b) #define chmax(a, b) a = max(a, b) #define pb push_back #define mp make_pair typedef long long ll; const int INF = 1 << 28; const ll INFLL = 1ll << 56; int main() { int l = 0, r = 1e9 + 1; while (l + 1 < r){ int m = (l + r) / 2; printf("? %d\n", m); fflush(stdout); int x; scanf("%d", &x); if (x) l = m; else r = m; } printf("! %d\n", l); fflush(stdout); }