#include <iostream>
#include <vector>
// Función para factorizar un número en primos
std::vector<int> factorizar(int n) {
std::vector<int> primos;
int i = 2;
while (i * i <= n) {
if (n % i == 0) {
primos.push_back(i);
n /= i;
} else {
i++;
}
}
if (n > 1) {
primos.push_back(n);
}
return primos;
}
// Función para calcular el número de divisores de un número
int contarDivisores(int n) {
std::vector<int> primos = factorizar(n);
int exponentes[primos.size()];
for (int i = 0; i < primos.size(); i++) {
exponentes[i] = 0;
}
for (int i = 0; i < primos.size(); i++) {
int p = primos[i];
while (n % p == 0) {
exponentes[i]++;
n /= p;
}
}
int divisores = 1;
for (int i = 0; i < primos.size(); i++) {
divisores *= (exponentes[i] + 1);
}
return divisores;
}
int main() {
int n;
std::cout << "Ingrese un número: ";
std::cin >> n;
int divisores = contarDivisores(n);
std::cout << "El número de divisores de " << n << " es: " << divisores << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKLy8gRnVuY2nDs24gcGFyYSBmYWN0b3JpemFyIHVuIG7Dum1lcm8gZW4gcHJpbW9zCnN0ZDo6dmVjdG9yPGludD4gZmFjdG9yaXphcihpbnQgbikgewogICAgc3RkOjp2ZWN0b3I8aW50PiBwcmltb3M7CiAgICBpbnQgaSA9IDI7CiAgICB3aGlsZSAoaSAqIGkgPD0gbikgewogICAgICAgIGlmIChuICUgaSA9PSAwKSB7CiAgICAgICAgICAgIHByaW1vcy5wdXNoX2JhY2soaSk7CiAgICAgICAgICAgIG4gLz0gaTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpKys7CiAgICAgICAgfQogICAgfQogICAgaWYgKG4gPiAxKSB7CiAgICAgICAgcHJpbW9zLnB1c2hfYmFjayhuKTsKICAgIH0KICAgIHJldHVybiBwcmltb3M7Cn0KCi8vIEZ1bmNpw7NuIHBhcmEgY2FsY3VsYXIgZWwgbsO6bWVybyBkZSBkaXZpc29yZXMgZGUgdW4gbsO6bWVybwppbnQgY29udGFyRGl2aX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