結果
| 問題 | 
                            No.246 質問と回答
                             | 
                    
| コンテスト | |
| ユーザー | 
                             spade630
                         | 
                    
| 提出日時 | 2015-10-19 11:48:29 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 341 bytes | 
| コンパイル時間 | 508 ms | 
| コンパイル使用メモリ | 54,284 KB | 
| 実行使用メモリ | 42,784 KB | 
| 最終ジャッジ日時 | 2024-07-16 19:55:43 | 
| 合計ジャッジ時間 | 6,782 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | TLE * 1 -- * 29 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:25: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=]
   13 |                 scanf("%d", res);
      |                        ~^   ~~~
      |                         |   |
      |                         |   int
      |                         int*
main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                 scanf("%d", res);
      |                 ~~~~~^~~~~~~~~~~
main.cpp:13:22: warning: ‘res’ is used uninitialized [-Wuninitialized]
   13 |                 scanf("%d", res);
      |                 ~~~~~^~~~~~~~~~~
            
            ソースコード
#include <iostream>
#include <cstdio>
using namespace std;
const int INF = 1e+9;
int main() {
	int lb = 0, ub = INF, res;
	while(ub - lb > 1){
		int mid = (lb + ub) / 2;
		printf("? %d\n", mid);
		fflush(stdin);
		scanf("%d", res);
		if(res){
			lb = mid;
		}
		else{
			ub = mid;
		}
	}
	printf("! %d\n", ub);
	fflush(stdin);
	return 0;
}
            
            
            
        
            
spade630