atcoder#NOMURA2020F. Sorting Game
Sorting Game
Score : points
Problem Statement
Takahashi and Snuke came up with a game that uses a number sequence, as follows:
- Prepare a sequence of length consisting of integers between and (inclusive): .
- Snuke first does the operation below as many times as he likes:
- Choose a positive integer , and for each , in binary, set the -th least significant bit of to . (Here the least significant bit is considered the -st least significant bit.)
- Choose a positive integer , and for each , in binary, set the -th least significant bit of to . (Here the least significant bit is considered the -st least significant bit.)
- After Snuke finishes doing operations, Takahashi tries to sort in ascending order by doing the operation below some number of times. Here is said to be in ascending order when for all .
- Choose two adjacent elements of : and . If, in binary, these numbers differ in exactly one bit, swap and .
- Choose two adjacent elements of : and . If, in binary, these numbers differ in exactly one bit, swap and .
There are different sequences of length consisting of integers between and that can be used in the game.
How many among them have the following property: if used in the game, there is always a way for Takahashi to sort the sequence in ascending order regardless of Snuke's operations? Find the count modulo .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number, modulo , of sequences with the property: if used in the game, there is always a way for Takahashi to sort the sequence in ascending order regardless of Snuke's operations.
2 5
352
Consider the case for example.
- When the least significant bit of each element of is set to , ;
- When the second least significant bit of each element of is set to , ;
- When the least two significant bits of each element of are set to , .
In all of the cases above and the case when Snuke does no operation to change , we can sort the sequence by repeatedly swapping adjacent elements that differ in exactly one bit. Thus, this sequence has the property: if used in the game, there is always a way for Takahashi to sort the sequence in ascending order regardless of Snuke's operations.
2020 530
823277409