spoj pizzaloc

Getting RUNtime error(sigsegv)
my solution link:
problem link:http://www.spoj.com/problems/PIZZALOC/
plssss help stuck since a month

Even if your solution pass and doesnot give run time error , i will give TLE , as you are running a loop upto 2^20 and will definitely TLE keeping in mind the time constraints .

there is no loop which is running for 10^20.but for intialization one is 10*20 and masking one 2^21

i mean 2^20 i , for this line of code m can go upto 20
for(i=0;i<pow(2,m);i++)
{if(countsetbits(i)==k)

I’m solving PIZZALOC but i think i’m clear with the question but for first sample case i got 26.
For three locations :
1 + 7 = 8
7 + 9 = 16
9 + 1 = 10
10 + 16 i.e 26
Here’s my code.
Pliz tell me what’s wrong with my logic.