結果

問題 No.253 ロウソクの長さ
ユーザー Kmcode1
提出日時 2015-07-25 02:42:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 919 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 93,816 KB
実行使用メモリ 25,476 KB
平均クエリ数 49.64
最終ジャッジ日時 2024-07-16 05:12:03
合計ジャッジ時間 3,556 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |                 scanf("%d", &ans0);
      |                 ~~~~~^~~~~~~~~~~~~
main.cpp:42:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   42 |                 scanf("%d", &ans1);
      |                 ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_map>
#include<stdint.h>
using namespace std;

int main(void) {
	int i, ask = (1 << 30), ans0, ans1 = -1, y=0;
	for (i = 0; i < 30; i++) {
		printf("? %d\n", 1); fflush(stdout);
		scanf("%d", &ans0);
		if (ans0 != 1) {
			y = 2 * i + (ans0 == 0);
			break;
		}

		ask += ans1 * (1 << (29 - i));
		printf("? %d\n", ask - (2 * i + 1)); fflush(stdout);
		scanf("%d", &ans1);
		if (ans1 == 0) {
			y = ask;
			break;
		}
	}
	printf("! %d\n", y); fflush(stdout);
	return 0;
}
0