fork download
  1. #include <stdio.h>
  2. #include <algorithm>
  3. using namespace std;
  4. int Find_aXa_y(int y)
  5. {
  6. int l = 1 , r = 100 , mid = l + (r - l) / 2;
  7. while(l < r)
  8. {
  9. mid = l + (r - l) / 2;
  10. if(1LL * mid * mid >= y)
  11. r = mid;
  12. else
  13. l = mid + 1;
  14. }
  15. return y / r == r ? r : -1;
  16. }
  17. int arr[11] = {2 , 3 , 4 , 6 , 9 , 1 , 11 , 8 , 6 , 4 , 1};
  18. int Find_MaxV_in_inc_dec_range()
  19. {
  20. int l = 0 , r = 10 , curr_mid = 0 , mid = l + (r - l + 1) / 2;
  21. while(l < r)
  22. {
  23. mid = l + (r - l + 1) / 2;
  24. if(arr[mid] > arr[curr_mid])
  25. l = mid , curr_mid = mid;
  26. else
  27. r = mid - 1;
  28. }
  29. return arr[curr_mid];
  30. }
  31. int main()
  32. {
  33. //int n;
  34. //scanf("%d" , &n);
  35. //printf("%d" , Find_aXa_y(n));
  36. printf("%d" , Find_MaxV_in_inc_dec_range());
  37. }
  38.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
9