I am getting WA in this question. please provide a correct solution.

My solutions : http://www.codechef.com/status/APGE01,himanshujaju

Ok, so in the question you have c undercover cops that have infiltrated the p prisoners, and you need to give them instructions to position them in the file for strategic advantage, so basically we have to distribute p prisioners into (c+1) equal parts. Cleary (c+1) equal parts are possible only when p%(c+1)==0

So incase of p%(c+1)==0 result is p/(c+1)

and incase of p%(c+1)!=0 result is p/(c+1)+1; since first we distribute p/(c+1) into each part and then we need to distribute the remaining p%(c+1) and clearly p%(c+1)<(c+1) therefore the result in this case is p%(c+1)+1, here is my solution :- http://www.codechef.com/viewsolution/2293581

Hope it helps

Please see this solution

your logic is correct but i guess there might be some problem with the ceil function.hence i am using my own ceil,

also cin and cout are slow so you might want to use faster I/O as number of input is large.