제출 #828910

#제출 시각아이디문제언어결과실행 시간메모리
828910Sputnik123Guess the number (BOI20_guess)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <string.h> #include <stdio.h> #include <algorithm> #include <vector> #include <functional> #include <cstdio> #define pb push_back #define in insert #define pll pair<ll,ll> #define vpl vector<pll> #define vll vector <ll> #define vl vector<ll> #define sl set<ll> #define msl multiset<ll> #define mll map<ll,ll> #define mmll multimap<ll,ll> #define mcl map<char,ll> #define mp make_pair #define F first #define S second #define all(v) v.begin(),v.end() #define endl "\n" #define speed ios_base::sync_with_stdio(false);cin.tie();cout.tie() #define ll long long #define ull unsigned long long #define LMX LLONG_MAX #define REP(i, n) for (ll i=0;i<(n);i++) #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) #define F0R(i, a) FOR(i, 0, a) #define ROF(i, a, b) for (ll i = (b)-1; i >= (a); --i) #define R0F(i, a) ROF(i, 0, a) //#define rep(a) F0R(_, a) #define each(a, x) for (auto &a : x) using namespace std; using namespace __gnu_pbds; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll gcd(ll a,ll b) { if(b==0) { return a; } return gcd(b,a%b); } ll lcm(ll a,ll b) { return (a/gcd(a,b))*b; } bool comp(pair <ll,ll> p1,pair <ll,ll> p2) { if(p1.first==p2.first) { return p1.second>p2.second; } return p1.first<p2.first; } ll my_abs(ll num) { return abs(static_cast<long long>(num)); } ll sgn(ll n) { return (n>0)-(n<0); } ll binpow(ll a,ll b,ll c) { ll res=1; a%=c; while(b>0) { if(b&1) res=res*a%c; a=a*a%c; b>>=1; } return res; } /* #pragma omp parallel for #pragma GCC optimize("0fast") #pragma GCC target ("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") */ void solve() { ll n; cin>>n; ll l=1,r=n; while(l<r) { ll mid=l+(r-l)/2; cout<<"? "<<mid<<endl; ll s; cin>>s; if(s==0) { cout<<"= "<<mid<<flush; return ; } else if(s==-1) { r=mid-1; } else { l=mid+1; } } } int main () { ll t=1; //cin>>t; while(t--) { solve(); } } /* string length */ /* auto locate = [&](int x) -> int { for (int i = 0; i < N; i++) if (P[i] == x) return i; return -1; }; function in funcition */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...