Whats wrong with the code

@aatish08,
You also have to initialise the p array with 0, when you declare it.


is this okay?
but its giving output as 0

@aatish08,
if(cnt==n)


All test cases passed,tle in last test case

@aatish08,
Yes, it will, because you are doing a redundant work in your algorithm again and again, try to think of optimising by precalculation.

Done thanks for the help