Guest User

Untitled

a guest
Dec 14th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. // ios_base::sync_with_stdio(false);
  6. // cin.tie(NULL);
  7.  
  8. long long n,c;
  9. cin>>n>>c;
  10. long long money=1000;
  11. long long start=1,end=n;
  12. while(start<=end){
  13. if( start == end ){
  14. cout<<"3 "<<start<<endl;
  15. break;
  16. }
  17. long long mid=start+(end-start)/2;
  18. if(money < 1){
  19. break; // not enough coins for query
  20. }
  21. money--;
  22. cout<<"1 "<<mid<<endl;
  23. int inp;
  24. cin>>inp;
  25. if(inp==1){
  26. if(money < c ){
  27. break; // not enough coins for repair
  28. }
  29. end=mid;
  30. cout<<'2'<<endl;
  31. money -= c;
  32. }else if(inp==0){
  33. start=mid+1;
  34. }else{
  35. break; // -1 resoponse
  36. }
  37. }
  38. return 0;
  39. }
Add Comment
Please, Sign In to add comment