結果

問題 No.253 ロウソクの長さ
ユーザー cielciel
提出日時 2015-07-25 01:27:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 780 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 26,232 KB
実行使用メモリ 24,480 KB
平均クエリ数 28.81
最終ジャッジ日時 2023-09-23 21:01:30
合計ジャッジ時間 3,145 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,700 KB
testcase_01 AC 25 ms
24,108 KB
testcase_02 AC 26 ms
23,448 KB
testcase_03 AC 26 ms
24,096 KB
testcase_04 AC 25 ms
24,072 KB
testcase_05 AC 26 ms
24,072 KB
testcase_06 AC 25 ms
23,436 KB
testcase_07 AC 25 ms
23,448 KB
testcase_08 AC 26 ms
24,072 KB
testcase_09 AC 25 ms
24,084 KB
testcase_10 AC 27 ms
24,084 KB
testcase_11 AC 26 ms
24,048 KB
testcase_12 AC 26 ms
24,108 KB
testcase_13 AC 26 ms
24,048 KB
testcase_14 AC 26 ms
23,568 KB
testcase_15 AC 25 ms
24,276 KB
testcase_16 AC 26 ms
23,424 KB
testcase_17 AC 25 ms
24,480 KB
testcase_18 AC 26 ms
23,568 KB
testcase_19 AC 27 ms
23,568 KB
testcase_20 AC 27 ms
23,556 KB
testcase_21 AC 26 ms
24,336 KB
testcase_22 AC 27 ms
24,360 KB
testcase_23 AC 26 ms
23,448 KB
testcase_24 AC 26 ms
23,688 KB
testcase_25 AC 27 ms
24,372 KB
testcase_26 AC 26 ms
23,676 KB
testcase_27 AC 26 ms
23,916 KB
testcase_28 AC 26 ms
23,724 KB
testcase_29 AC 27 ms
23,676 KB
testcase_30 AC 26 ms
24,084 KB
testcase_31 AC 26 ms
23,592 KB
testcase_32 AC 26 ms
23,412 KB
testcase_33 AC 26 ms
24,264 KB
testcase_34 AC 25 ms
24,060 KB
testcase_35 AC 27 ms
23,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>

int ask(int t){
	printf("? %d\n",t);
	fflush(stdout);
	int f;
	scanf("%d",&f);
	return f;
}
__attribute__((noreturn)) int ans(int t){
	printf("! %d\n",t);
	exit(0);
}

// cpp_binarysearch (C) @cielavenir under Boost Software License.
// type F should be something like std::function<bool(T)>.

template<typename T,typename F>
T binarysearch(T lo,T hi,T eps,const F &checker){
	for(int i=1;lo+eps<hi;i++){
		T mi=(lo+hi)/2;
		int z=checker(mi-i);
		if(z==0)return mi;
		if(z==1)lo=mi+1;
		if(z==-1)hi=mi;
	}
	return lo;
}
template<typename T,typename F>
T binarysearch(T lo,T hi,const F &checker){return binarysearch(lo,hi,1,checker);}

int main(){
	if(ask(35)==-1)for(int i=1;;i++)if(ask(0)==0)ans(i);
	ans(binarysearch(10,1000000000,ask));
}
0