The link to my code is http://ideone.com/CLOFdB
Please help me to find out why I am getting SIGFPE error in this code on spoj.
Thanks in Advance.
SIGFPE is a divide by zero error.Just store something in a[1] and a[ number which are prime ] because whenever they will be accessed, then if you divide by a[i] it can go infinite. If a number is prime store a[i]=i and in 1 you can store 1 or you make sure these values are not used
The above comments explains you about SIGFEPE. I would like to add some extra point about your code.
Your approach will give a TLE. As you are calculating everything again and again during each test case. You can follow this to avoid TLE:

Calculate all the primes using Sieve. (which you did)

Store all the number of distinct prime factors of each element ranging from 2,1000000(=MAX).
m are the number of primes that you got using Sieve. a is the array in which they are stored.*for(int i = 0;i<m;i++){
ll j = 1; while(a[i]*j<=MAX){ p[a[i]*j]++; //p is initialized with 0 j++; }
}*

Store in 2D vector the n factorful ,i.e., q[k].push_back(i) {if i is a k factorful}
q[0].push_back(1); //given in the question
for(int i = 2;i<=MAX;i++){
q[p[i]].push_back(i);
}

Apply lower_bound and upper_bound and give the answer.
vector::iterator l,u;
while(tâ€“){
scanf("%d%d%d",&a,&b,&n); l = lower_bound(q[n].begin(),q[n].end(),a); u = upper_bound(q[n].begin(),q[n].end(),b); printf("%d\n",ul);
}
Can you please explain me the code in C language?I dont know this concept of vectorâ€¦Thanks
First two points will be same.
In 3rd point use 2D array (it will be of size [10][x] x can be MAX for worst case).
In 4th point apply simple iteration and count if(q[n][i] belongs to [a,b]).
Hope its clear now