Modulo 4
시간 제한1초메모리 제한2048 MB
0, 1, |로 이루어진 길이 k의 문자열 가운데 접미사로 2^n-1 값을 갖는 식을 포함하는 것의 개수를 4로 나눈 나머지를 구한다.
문제
Let be the set of all arithmetic expressions consisting of the digits 0, 1, and the bitwise OR operator |, starting with 1, such that there is a 1 immediately after each |.
Let be the subset of all expressions from such that their value is equal to when considering the numbers in the expression in binary.
Let be the subset of all expressions from containing at least one expression from the set as a suffix. For example, the following expressions are in : 10011111, 111, 110|1|11, 11|11001|1010|101, and these expressions are not in : 111|1011, 1, 10|11|11, 1100|10|100.
For given positive integers and , find the number of expressions from the set that contain exactly digits (and an arbitrary number of |). As the answer may be very large, output it modulo~.
입력
The input contains test cases. The value is given on the first line of input.
The only line in each test case contains two integers and (, ).
출력
For each test case, output the number of expressions from the set containing exactly digits, modulo~.
힌트
Here are expressions from the first example:
1111, 1011, 1|111, 111|1, 110|1, 11|11, 10|11, 11|10, 10|1|1, 11|1|1, 1|10|1, 1|11|1, 1|1|10, 1|1|11