結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
![]() |
提出日時 | 2015-07-25 03:22:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 494 bytes |
コンパイル時間 | 414 ms |
コンパイル使用メモリ | 27,648 KB |
実行使用メモリ | 26,356 KB |
平均クエリ数 | 49.64 |
最終ジャッジ日時 | 2025-02-07 08:46:28 |
合計ジャッジ時間 | 3,100 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d", &ans0); | ~~~~~^~~~~~~~~~~~~ main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d", &ans1); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h> int main(void) { int i, ask = (1 << 29), ans0, ans1 = -1; for(i = 0; i < 30; i++) { printf("? %d\n", 1); fflush(stdout); scanf("%d", &ans0); if(ans0 != 1) { ask = 2 * i + (ans0 == 0); break; } int t = ask - (2 * i + 1); //t = (t < 0 ? 0 : t); printf("? %d\n", t ); fflush(stdout); scanf("%d", &ans1); int j = 28 - i; j = (j < 0 ? 0 : j); ask += ans1 * (1 << j); if(ans1 == 0) { break; } } printf("! %d\n", ask); fflush(stdout); return 0; }