結果

問題 No.253 ロウソクの長さ
ユーザー kyuridenamidakyuridenamida
提出日時 2015-07-24 23:42:09
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,954 bytes
コンパイル時間 1,199 ms
コンパイル使用メモリ 146,072 KB
実行使用メモリ 24,480 KB
平均クエリ数 27.94
最終ジャッジ日時 2023-09-23 05:01:44
合計ジャッジ時間 6,711 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,952 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 26 ms
23,844 KB
testcase_07 AC 26 ms
24,048 KB
testcase_08 AC 27 ms
23,436 KB
testcase_09 RE -
testcase_10 AC 26 ms
23,940 KB
testcase_11 AC 26 ms
24,240 KB
testcase_12 AC 26 ms
23,952 KB
testcase_13 AC 26 ms
23,544 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 27 ms
23,964 KB
testcase_17 AC 27 ms
23,388 KB
testcase_18 AC 26 ms
23,532 KB
testcase_19 AC 26 ms
24,024 KB
testcase_20 AC 26 ms
24,264 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 25 ms
23,952 KB
testcase_24 RE -
testcase_25 AC 25 ms
23,676 KB
testcase_26 AC 26 ms
23,424 KB
testcase_27 AC 25 ms
24,336 KB
testcase_28 AC 26 ms
24,228 KB
testcase_29 AC 27 ms
24,192 KB
testcase_30 AC 27 ms
24,048 KB
testcase_31 AC 25 ms
24,048 KB
testcase_32 AC 26 ms
23,388 KB
testcase_33 AC 26 ms
23,616 KB
testcase_34 RE -
testcase_35 AC 27 ms
23,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b){
	return b ? gcd(b,a%b) : a;
}
long long lcm(long long a,long long b){
	return a / gcd(a,b) * b;
}

long long mul(long long a,long long b,const long long mod){
	return b?(mul(a*2,b/2,mod)+(b&1?a:0))%mod:0;
}

long long bpow(long long a,long long b,const long long mod){
	return (b?bpow(a*a%mod,b/2,mod)*(b&1?a:1):1)%mod;
}

long long inv(long long a,const long long mod){
	return bpow(a,mod-2,mod);
}

// to overflow
/*long long bpow(long long a,long long b,const long long mod){
	return (b?mul(bpow(mul(a,a,mod),b/2,mod),(b&1?a:1),mod):1)%mod;
}*/
class mInt{
public:
	static const long long mod = 1000000007;
	long long v;
	mInt():v(0){}
	mInt(long long v):v((v%mod+mod)%mod){}
};
mInt& operator += (mInt &a,mInt b){ return a = a.v + b.v; }
mInt& operator -= (mInt &a,mInt b){ return a = a.v - b.v; }
mInt& operator *= (mInt &a,mInt b){ return a = a.v * b.v; }
mInt& operator /= (mInt &a,mInt b){ return a = a.v * inv(b.v,mInt::mod); }
mInt operator + (mInt a,mInt b){ return a += b; }
mInt operator - (mInt a,mInt b){ return a -= b; }
mInt operator * (mInt a,mInt b){ return a *= b; }
mInt operator / (mInt a,mInt b){ return a /= b; }
ostream& operator<<(ostream& os, const mInt& x){ return os << x.v; }

double ncr1[4000][4000];
long long ncr2[4000][4000];

long long nHr(int n,int r){
	int a = n + r - 1;
	int b = r-1;
	if( ncr1[a][b] > 1e17 ) return 1e17;
	return ncr2[a][b];
}


int Q(int n){
	cout << "? " << n << endl;
	string s1;
	int ans;
	cin >> ans;
	return ans;
}

int D(int a){
	cout << "! " << a << endl;
	exit(0);
}

int main(){
	int T = 0;
	T++;
	if( Q(100) == -1 ){
		for(int i = 0 ; i < 100 ; i++ ){
			int t = Q(i);
			assert(t!=-1);
			if( t == 0 ) D(i+T);
			T++;
		}
	}else{
		int l = 0 , r = 1e9;
		while( l != r ){
			int m = (l+r+1) / 2;
			if( Q(m-T) == -1 ){ // Y < (?)
				r = m-1;
			}else{
				l = m;
			}
			T++;
		}
		D(l);
		
	}
	
	
}
0