eolymp
bolt
Try our new interface for solving problems
Problems

Binomial coefficients 5

Binomial coefficients 5

You are given a positive integer \textbf{n <= 40} and non-negative integer \textbf{r < 2^n}. Find all integers \textbf{k} from \textbf{0} to \textbf{2^n-1} such that \textbf{C(2^n-1,k) mod 2^n = r}. \InputFile The input file contains \textbf{T < 400} test cases. The first line of the input file contains the integer \textbf{T}. Each of the following \textbf{T} lines describes one test case and contains the numbers \textbf{n} and \textbf{r} separated by space. \OutputFile The output file should consist of \textbf{T} lines. Each line should contain the number of the required values of \textbf{k} followed by these values in increasing order for the corresponding test case from the input file. Numbers in the line should be separated by spaces.
Time limit 3 seconds
Memory limit 64 MiB
Input example #1
3
1 0
1 1
3 7
Output example #1
0
2 0 1
2 1 6