結果
| 問題 | No.246 質問と回答 |
| コンテスト | |
| ユーザー |
184
|
| 提出日時 | 2015-07-17 23:49:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 735 bytes |
| 記録 | |
| コンパイル時間 | 636 ms |
| コンパイル使用メモリ | 63,472 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 30.90 |
| 最終ジャッジ日時 | 2024-07-16 07:07:08 |
| 合計ジャッジ時間 | 3,474 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d",&res);
| ~~~~~^~~~~~~~~~~
main.cpp:24:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%d",&res);
| ~~~~~^~~~~~~~~~~
main.cpp:34:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
34 | scanf("%d",&res);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
//namaega184
int main(){
int left=1,right=1000000000,mid=0;
while(left<right){
mid=(left+right)/2;
//printf("? %d",mid);
//fflush(stdout);
cout << "? " << mid << endl;
int res;
scanf("%d",&res);
if(res){
left=mid;
if(left+1==right){
cout << "? " << right << endl;
scanf("%d",&res);
if(res)mid=right;
break;
}
}
else{
right=mid-1;
if(left+1==right){
cout << "? " << right << endl;
scanf("%d",&res);
if(res)mid=right;
else mid=left;
break;
}
}
}
cout << "! " << mid << endl;
//printf("! %d\n",mid);
//fflush(stdout);
return 0;
}
184