LEPAINT - Editorial

Yes tec, I noticed the same pattern too. It’s just that I didn’t want to code adding color occurrences after checking their gcd. I have updated my answer. :slight_smile:

Then the complexity is already down to O(K*max(N,u^2)), (u is the number of divisors of c), which is almost O(KN).

I have a doubt. Suppose we know L <= j <= R. // if( j>=L && j<=R)//
Why did we still consider this below condition even we know L <= j <= R??
//if you don’t chose it [ probability that you do not take it in subset is 0.5 ]
//dp[i][j][k] += dp[i-1][j][k]*0.5

am i the only one who didnt understood the solution