O-papal
Find number of different palindromic numbers, even length K, written in base B possible to made from matrix NxN of digits. You can made numbers starting from any digit from matrix and then adding any of eight neighbors until reach length K.
InputIn first line of input are three integers N,K i B, (1 <= N <= 10), (1 < K < 13), (2 <= B <=10).
Digit is integer from 0 to 9.
Digit is integer from 0 to 9.
OutputIn first line of output write number of different palindromic numbers, even length K, written in base B, using given matrix.
NOTICE:
20% : N,K,B <= 4
40% : N,K,B <= 6
60% : N,K,B <= 8
80% : N,K,B <= 10
Input:
5 4 4
11111
11111
10217
13117
11154
Output:
3
Explanation: possible palindromic numbers of length 4, written in base 4 are: 1111, 2112, and 3113.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.