eolymp
bolt
Try our new interface for solving problems
Problems

Adjacent Bit Counts

Adjacent Bit Counts

For a string of \textbf{n} bits \textbf{x_1}, \textbf{x_2}, \textbf{x_3}, …, \textbf{x_n}, the adjacent bit count of the string (\textbf{AdjBC(x)}) is given by \textbf{x_1·x_2 + x_2·x_3 + x_3·x_4 + … + x_\{n-1\}·x_n} which counts the number of times a \textbf{1} bit is adjacent to another \textbf{1} bit. For example: \textbf{AdjBC(011101101) = 3AdjBC(111101101) = 4AdjBC(010101010) = 0} Write a program which takes as input integers \textbf{n} and \textbf{k} and returns the number of bit strings \textbf{x} of \textbf{n} bits (out of \textbf{2^n}) that satisfy \textbf{AdjBC(x) = k}. For example, for \textbf{5} bit strings, there are \textbf{6} ways of getting \textbf{AdjBC(x) = 2}: \textbf{11100, 01110, 00111, 10111, 11101, 11011} \InputFile The first line of input contains a single integer \textbf{P}, (\textbf{1} ≤ \textbf{P} ≤ \textbf{1000}), which is the number of data sets that follow. Each data set is a single line that contains the data set number, followed by a space, followed by a decimal integer giving the number (\textbf{n}) of bits in the bit strings, followed by a single space, followed by a decimal integer (\textbf{k}) giving the desired adjacent bit count. The number of bits (\textbf{n}) will not be greater than \textbf{100} and the parameters \textbf{n} and \textbf{k} will be chosen so that the result will fit in a signed \textbf{32}-bit integer. \OutputFile For each data set there is one line of output. It contains the data set number followed by a single space, followed by the number of \textbf{n}-bit strings with adjacent bit count equal to \textbf{k}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
10
1 5 2
2 20 8
3 30 17
4 40 24
5 50 37
6 60 52
7 70 59
8 80 73
9 90 84
10 100 90
Output example #1
1 6
2 63426
3 1861225
4 168212501
5 44874764
6 160916
7 22937308
8 99167
9 15476
10 23076518
Source Greater New York Regional 2009