 # LOCJUN17 PCAKE Solution Problem

Can anyone explain me where I am wrong in my approach in my solution to the question PCAKE of LOCJUN17.

I have only been able to get the question partially correct.

My Approach :

I have store the prime factorization of each number in separate arrays and a Boolean variable visible to denote whether the number has repeated prime number in its factorization. By default the Boolean value for the number is True, the Boolean value for the number with repeated prime number in its factorization is kept false and is not taken in consideration in the computation of the answer.

Then checked the subsets which do not have common factor and counted them to compute the answer.

``````if(arr[i].visible)
{
j=0;
while(j<=arr[i].top)
{
temp=arr[i].prime[j];
if (position[temp]==-1)
position[temp]=i;
else
{
int z=position[temp]+1;
for(int k=prev;k<=position[temp];k++)
{
int x=0;
while(x<=arr[k].top)
{
position[arr[k].prime[x]]=-1;
x++;
}
}
prev=z;
position[temp]=i;
}
j++;
}
ans+=i-prev+1;
}
else
{
for(int k=prev;k<i;k++)
{
int x=0;
while(x<=arr[k].top)
{
position[arr[k].prime[x]]=-1;
x++;
}
}
prev=i+1;
}
}
``````
1 Like