結果

問題 No.253 ロウソクの長さ
コンテスト
ユーザー Kmcode1
提出日時 2015-07-25 02:44:07
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 977 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 609 ms
コンパイル使用メモリ 113,268 KB
実行使用メモリ 28,976 KB
平均クエリ数 4.33
最終ジャッジ日時 2026-03-30 19:24:41
合計ジャッジ時間 8,912 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:41:33: warning: 'k' may be used uninitialized [-Wmaybe-uninitialized]
   41 |                 int k = ask - (k*i + 1);
      |                                ~^~
main.cpp:41:21: note: 'k' was declared here
   41 |                 int k = ask - (k*i + 1);
      |                     ^

ソースコード

diff #
raw source code

#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));
		int k = ask - (k*i + 1);
		if (k < 0){
			return 1;
		}
		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