#include <iostream>
#include <cmath>
using namespace std;
double SzescianPierwiastek(double N, double e = 0.0001) {
double left = 0, right = (N >= 1) ? N : 1;
while (right - left > e){
double mid = (left + right) /2;
double midPierwiastek = mid * mid * mid;
if (midPierwiastek > N)
right = mid;
else
left = mid;
}
return (left + right) /2;
}
int main()
{
double N;
cout << "Podaj liczbę: ";
cin >> N;
double result = SzescianPierwiastek(N);
cout << "Pierwiastek sześcienny z " << N << " wynosi: " <<result << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpkb3VibGUgU3plc2NpYW5QaWVyd2lhc3Rlayhkb3VibGUgTiwgZG91YmxlIGUgPSAwLjAwMDEpIHsKCWRvdWJsZSBsZWZ0ID0gMCwgcmlnaHQgPSAoTiA+PSAxKSA/IE4gOiAxOwoJCgl3aGlsZSAocmlnaHQgLSBsZWZ0ID4gZSl7CgkJZG91YmxlIG1pZCA9IChsZWZ0ICsgcmlnaHQpIC8yOwoJCWRvdWJsZSBtaWRQaWVyd2lhc3RlayA9IG1pZCAqIG1pZCAqIG1pZDsKCQkKCQlpZiAobWlkUGllcndpYXN0ZWsgPiBOKQoJCSByaWdodCA9IG1pZDsKCQkgCgkJIGVsc2UgCgkJCgkJIGxlZnQgPSBtaWQ7Cgl9CglyZXR1cm4gKGxlZnQgKyByaWdodCkgLzI7Cn0KCWludCBtYWluKCkKCXsKCQlkb3VibGUgTjsKCQljb3V0IDw8ICJQb2RhaiBsaWN6YsSZOiAiOwoJCWNpbiA+PiBOOwoJCQoJCWRvdWJsZSByZXN1bHQgPSBTemVzY2lhblBpZXJ3aWFzdGVrKE4pOwoJCWNvdXQgPDwgIlBpZXJ3aWFzdGVrIHN6ZcWbY2llbm55IHogIiA8PCBOIDw8ICIgd3lub3NpOiAiIDw8cmVzdWx0IDw8IGVuZGw7CgkJcmV0dXJuIDA7Cgl9Cg==