https://www.codechef.com/JCWR2019/problems/JCWC02

Has anyone solve this problem through dp??

if yes pls share approach

https://www.codechef.com/JCWR2019/problems/JCWC02

Has anyone solve this problem through dp??

if yes pls share approach

I did this with dp. The idea is to maintain two variables (number of odd numbers and number of even numbers). Have a look at my submission

My solution : https://www.codechef.com/viewsolution/25948437

There are two states .dp[i][0] indicates count of number having summation as even until current i and dp[i][1] indicates count having summation as odd.

now u can build recuurence relation as:

dp[i][0]=dp[i-1][1]* (count of odd numbers in current index)+dp[i-1][0]* (count of even numbers in current index)

dp[i][1]=dp[i-1][0]* (count of odd numbers in current index)+dp[i-1][1]* (count of even numbers in current index)

finally the ans will be dp[n][1]