## 294 - Divisors

All about problems in Volume 2. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 294 please help me

Kamarul Kawnayeen wrote:A better approach to solve this problem should be using prime divisor. If you can find that a number N = (a^x)*(b^y)*(c^z) where a, b, c are prime number then the number of divisor of N should be (x+1)*(y+1)*(Z+1).

If you have already solve 583 (prime factor) then it will be easier for you to solve this problem.

Code: Select all

``````int divisors (long int c) {

long int s;
int i, j, flag;
int divisornum = 1;
i = 0;
flag = 0;

for(j=0;j<k;j++)
{
factor[j] = 0;
}

k = 0;

if(c<0)
{
c = - c;
}

s = sqrt(c);

while((c>=prime[i] && prime[i]<=s) && c!=1) //prime is an array which hold the prime number
{
j = 0;
while((c%prime[i])==0)
{
flag = 1;
c = c/prime[i];
j++;
}

if(flag==1)
{
factor[k] = j;    //save the power of a prime factor to another array
k++;
}
flag = 0;

i++;

}
if(c>1)
{
factor[k] = 1;
k++;
}

for(j=0;j<k;j++)
{
divisornum = divisornum * (factor[j]+1);        //applying the process which I describe earlier
}

return divisornum;

}``````
first done the seive code and find out prime number upto 56000 (approximately). Then use this code for finding number of divisor.
Check input and AC output for thousands of problems on uDebug!

LMast
New poster
Posts: 1
Joined: Mon Jul 06, 2015 3:25 am

### Problem with 294 problem, I dont know why :(

Hi guys, I dont know why my code return WA fot this problem.
I try found the error but i cant, in my console the answer is right.
Well, here is the code:
http://pastebin.com/QcyN3Wun

Thanks guys, I try really hard solve this problem