Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define endl "\n"
- using namespace std;
- double find_sqrt(int n) {
- double L = 0, R = n;
- while(fabs(L-R) >= 1e-4) {
- double M = (L+R) / 2;
- if(M*M < n) {
- L = M;
- } else {
- R = M;
- }
- }
- return L;
- }
- int main() {
- int n;
- cin >> n;
- cout << find_sqrt(n) << endl;
- main();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement