Advertisement
MaxObznyi

Q.17

Nov 17th, 2019
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long long solve(long long a) {
  5. long long l = 0, r = 1e9 + 1;
  6. while (l < r - 1) {
  7. long long m = (l + r) / 2;
  8. if (m * m <= a)
  9. l = m;
  10. else
  11. r = m;
  12. }
  13. return l;
  14. }
  15.  
  16. int main()
  17. {
  18. long long a;
  19. cin >> a;
  20. cout << solve(a);
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement