Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- // ios_base::sync_with_stdio(false);
- // cin.tie(NULL);
- long long n,c;
- cin>>n>>c;
- long long money=1000;
- long long start=1,end=n;
- while(start<=end){
- if( start == end ){
- cout<<"3 "<<start<<endl;
- break;
- }
- long long mid=start+(end-start)/2;
- if(money < 1){
- break; // not enough coins for query
- }
- money--;
- cout<<"1 "<<mid<<endl;
- int inp;
- cin>>inp;
- if(inp==1){
- if(money < c ){
- break; // not enough coins for repair
- }
- end=mid;
- cout<<'2'<<endl;
- money -= c;
- }else if(inp==0){
- start=mid+1;
- }else{
- break; // -1 resoponse
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment