Andrew and the Meatballs again (practice -easy)

http://www.codechef.com/viewsolution/2287181
Here is my solution for the problem Andrew and the Meatballs again in practice session under easy ones.
Can anybody help me regarding my solution…its giving wrong answer on submission but during my testing all cases are computed perfectly…please help…:frowning:

Your output at n=1 and k=1 is -1… see this

1 Like

if(k >n/2) //for k==1 && n==1 … n/2=0 … therefore (k>n/2) results to true and it prints -1…
printf("-1\n");

Use the above condition after the condition… if(n==1 && k==1) printf(“1\n”);

1 Like

thanks guys…!!!