Problem Statement | |||||||||||||
The top few rows of Pascal's triangle are drawn below: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1The leftmost and rightmost values of a particular row are always 1. An inner value v can be found by adding together the 2 numbers found immediately above v, on its right and left sides. For example, the 6 in the above figure is the sum of the two 3s above it. Return the number of values in row i of Pascal's triangle that are evenly divisible by d. The rows are 0-based, so row 3 contains 1,3,3,1. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | The jth element (0-based) of row i can be computed by the formula: i!where k! = 1*2*...*k and 0! = 1. | ||||||||||||
Constraints | |||||||||||||
- | i will be between 0 and 5000000 inclusive. | ||||||||||||
- | d will be between 2 and 6 inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|