Hello, there is a problem https://www.codechef.com/problems/SNCK05 which asks to find the number of compositions of n with summands of 1 or 2. I have got AC for this problem, but in my opinion, it has “off-by-one” error on the given numbers. For instance, in my opinion, 2 could be represented in two ways: 2=1+1 or 2=2, but the given answer in the samples is 1. n=4 could be represented in 5 ways: 1+1+1+1, 1+1+2, 1+2+1, 2+1+1 or 2+2. However, the given answer is 3. Is this really correct? If so, could you explain me how?

2 Likes

Thank for reporting. It’s been edited now, clarifying the mistake.