#P6871. [COCI 2013/2014 #6] HASH

[COCI 2013/2014 #6] HASH

Background

Mirko is studying a hash function.

Problem Description

This hash function is defined as follows:

  • f(NULL)=0f(\rm{NULL})=0
  • $f(a_i+s_i)=((f(s_i)\times33)\operatorname{xor}\ \operatorname{ord}(a_i))\bmod MOD$

Here, aia_i represents a character and sis_i represents a string. Both consist of lowercase letters.

  • xor\operatorname{xor} denotes the bitwise XOR operator.
  • ord(letter)\operatorname{ord(letter)} denotes the position of the letter in the alphabet (for example, ord(a)=1\operatorname{ord(a)=1} and ord(z)=26\operatorname{ord(z)= 26}).

MODMOD is an integer of the form 2m2^m.

When m=10m=10, some values of the hash function are:

  • f(a)=1f(\texttt{a})=1
  • f(aa)=32f(\texttt{aa})=32
  • f(kit)=438f(\texttt{kit})=438

How many words have hash value kk and length nn?

Input Format

One line containing three integers nn, kk, and mm.

Output Format

Output one line containing the number of words of length nn whose hash value is kk.

1 0 10 
0
1 2 10
1
3 16 10
4

Hint

Sample Explanation

Sample 1 Explanation

All characters in the alphabet have ord\text{ord} values that are not 00.

Sample 2 Explanation

The word is b.

Sample 3 Explanation

The words are dxl, hph, lxd, and xpx.

Constraints

1n101\le n\le 100k<2m0\le k<2^m6m256\le m\le 25

Notes

Translated from COCI2013-2014 CONTEST #6 T5 HASH.

Translated by ChatGPT 5