結果

問題 No.3212 SUPER Guess the Number
ユーザー pengin_2000
提出日時 2025-07-25 22:57:50
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 26,828 KB
実行使用メモリ 25,960 KB
平均クエリ数 21.83
最終ジャッジ日時 2025-07-25 22:57:52
合計ジャッジ時間 1,327 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:19:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |                 scanf("%lld", &res);
      |                 ^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int main()
{
	long long int i;
	long long int x[32], xx;
	long long int min, mid, max;
	min = 0;
	max = 1e6;
	printf("? -100000000\n");
	fflush(stdout);
	x[0] = -1e8;
	long long int res;
	for (xx = 1; max - min > 1; xx++)
	{
		mid = (max + min) / 2;
		x[xx] = 2 * mid - x[xx - 1] + 1;
		printf("? %lld\n", x[xx]);
		fflush(stdout);
		scanf("%lld", &res);
		if (res < 0)
			return 0;
		if (x[xx - 1] < min)
		{
			if (res > 0)
				min = mid;
			else
				max = mid;
		}
		else
		{
			if (res == 0)
				min = mid;
			else
				max = mid;
		}
	}
	printf("! %lld\n", max);
	fflush(stdout);
	return 0;
}
0