#include <iostream>
#include <cmath>
using namespace std;
unsigned long long integerCubeRoot(unsigned long long n) {
unsigned long long left = 0;
unsigned long long right = n;
while (left <= right) {
unsigned long long mid = (left + right) / 2;
unsigned long long cube = mid * mid * mid;
if (cube == n) {
return mid;
} else if (cube < n) {
left = mid + 1;
} else {
right = mid - 1;
}
return right;
int main() {
unsigned long long n;
cout << "Podaj liczbę n: ";
cin >> n;
if (n >= 0 && n <= 1000000000000000000) {
unsigned long long result = integerCubeRoot(n);
cout << "Część całkowita pierwiastka sześciennego z n: " << result << endl;
cout << "Liczba n jest spoza zakresu." << endl;
return 0;
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
#include <iostream>
#include <cmath>
using namespace std;
unsigned long long integerCubeRoot(unsigned long long n) {
unsigned long long left = 0;
unsigned long long right = n;
while (left <= right) {
unsigned long long mid = (left + right) / 2;
unsigned long long cube = mid * mid * mid;
if (cube == n) {
return mid;
} else if (cube < n) {
left = mid + 1;
} else {
right = mid - 1;
}
}
return right;
}
int main() {
unsigned long long n;
cout << "Podaj liczbę n: ";
cin >> n;
if (n >= 0 && n <= 1000000000000000000) {
unsigned long long result = integerCubeRoot(n);
cout << "Część całkowita pierwiastka sześciennego z n: " << result << endl;
} else {
cout << "Liczba n jest spoza zakresu." << endl;
}
return 0;
}