Magical Pascal

Given an integer N, find the number of elements which are even in the first N rows of the Pascal’s t…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

Any hint for this problem…i came with a solution which is for nth row but can’t find for first nth row

Hi Rashidul_du,

The main idea is to first solve how many odd numbers are there in the n-th row. The answer is 2^x, where x is the number of 1’s in the binary representation of n. You’ll need digit-dp to calculate how many odd numbers are there in the first n rows.

Hope this helps.

Yeah…but when the number is too big…I am getting CLE…even though I tried that approach