# Tag Info

The bitwise and of the bet and result is nonzero if and only if the bet is winning. Further, the bitwise and has exactly one bit set if the bet wins. To see this, note that the encoding of a bet has bit $1$ set iff it wins if the home team wins, bit $2$ set iff it wins if the game is a draw, and bit $4$ set iff it wins if the away team wins. For example, ...
Let us denote the array ways after $t$ iterations of the outer loop by $w_t$. The recurrence implemented by the code is $$w_0(n) = \begin{cases} 1 & \text{if } n = 0, \\ 0 & \text{if } n > 0. \end{cases} \\ w_t(n) = \begin{cases} w_{t-1}(n) & \text{if } n < t, \\ w_{t-1}(n) + w_t(n-t) & \text{if } n \geq t. \end{cases}$$ You can prove ...