I have been given x and k, where x is the number of factors of a number A, and k is the number of prime fact
First your implementation is too inefficient
Don't call a function inside the for loop like this
for (long long int numbers = 1; numbers < pow(10, 9) && !stop; numbers++)
pow will be called unnecessarily on each iteration. Save every constant to a variable before the loop. But in this case just use numbers < 1e9
To get all factors of n you just need to loop until sqrt(n). You're doing for (long long int a = 1; a <= numbers && !stop; a++) { if (numbers % a == 0) { so for example instead of only 104 loops for 108 you'll need 108 loops. If numbers % a == 0 then both a and numbers/a are factors of numbers
But the real issue here is that your algorithm is flawed. You can get all factors of A if you know the prime factors of A and their exponents. If A = p1m p2n ... pkp then A will have the following factors:
This is purely a combination counting issue that can be done easily without even knowing A. Notice that the number of factors from k prime factors has some relation to the number of factors from k-1 prime factors