結果
| 問題 |
No.246 質問と回答
|
| コンテスト | |
| ユーザー |
くれちー
|
| 提出日時 | 2016-12-27 16:14:56 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 2,000 ms |
| コード長 | 287 bytes |
| コンパイル時間 | 254 ms |
| コンパイル使用メモリ | 20,864 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 30.90 |
| 最終ジャッジ日時 | 2024-07-16 20:08:45 |
| 合計ジャッジ時間 | 3,497 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d", &b);
| ^~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main() {
int top = 1, tail = 1e9, b;
while (1) {
printf("? %d\n", (top + tail) / 2);
fflush(stdout);
scanf("%d", &b);
if (b) top = (top + tail) / 2;
else tail = (top + tail) / 2;
if (top == tail - 1) break;
}
printf("! %d\n", top);
return 0;
}
くれちー