結果

問題 No.253 ロウソクの長さ
ユーザー fiordfiord
提出日時 2015-07-25 00:24:06
言語 C++11
(gcc 13.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 558 bytes
コンパイル時間 1,229 ms
コンパイル使用メモリ 157,404 KB
実行使用メモリ 40,880 KB
最終ジャッジ日時 2024-07-16 20:50:42
合計ジャッジ時間 7,665 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 int ans;        scanf("%d",&ans);
      |                                 ~~~~~^~~~~~~~~~~
main.cpp:19:38: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |                 int ans;        scanf("%d",&ans);
      |                                 ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	int ple=100;
	int left=1e9,right=10;
	int cnt=0;
	for(;cnt<10;cnt++){
		printf("?%d\n",(ple+right)/2);
		int ans;	scanf("%d",&ans);
		if(ans==0){
			printf("!%d\n",(ple+right)/2+cnt);
			return 0;
		}
		else if(ans==1)	right=(ple+right)/2;
		else 	ple=(ple+right)/2;
	}
	for(;cnt<100;cnt++){
		printf("?%d\n",(left+right)/2);
		int ans;	scanf("%d",&ans);
		if(ans==0){
			printf("!%d\n",(left+right)/2+cnt);
			return 0;
		}
		else if(ans==1)	right=(left+right)/2;
		else 	left=(left+right)/2;
	}
}
0