結果

問題 No.253 ロウソクの長さ
コンテスト
ユーザー 唐澤貴洋
提出日時 2015-10-17 20:15:22
言語 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
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 921 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 507 ms
コンパイル使用メモリ 94,464 KB
実行使用メモリ 28,976 KB
平均クエリ数 33.97
最終ジャッジ日時 2026-03-31 10:50:49
合計ジャッジ時間 2,816 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<bitset>
#include<array>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<numeric>
#define D int
#define U unsigned
using namespace std;
D n, m, a, b, d, e;
char c;
bool g, h;
string s;
D threex[3] = { 0,1,1 };
D threey[3] = { 1,1,0 };
D ans;
D p[102][102],q[102][102];
int main() {
	D i, j, k;
	D t, u;
	cout << "? 100" << endl;
	cin >> t;
	if (t == 0) {
		cout << "! 100" << endl;
	}
	else if (t==-1) {
		for (i = 1; i < 100; i++) {
			cout << "? 0" << endl;
			cin >> t;
			if (t == 0)
				break;
		}
		cout << "! " << i << endl;
	}
	else {
		u = 0;
		for (i = 29; i >= 0; i--) {
			u += 1 << i;
			cout << "? " << u - (30 - i) << endl;
			cin >> t;
			if (t == 0) {
				cout << "! " << u << endl;
				break;
			}
			else if (t == -1) {
				u -= 1 << i;
			}
		}
	}
}
0