Perfect Sets
Time limit2sMemory limit512 MB
Count the subsets of {0,...,k} closed under bitwise XOR, where k can be as large as 10^9, modulo 10^9+7.
- Level
Medium7 of 10
- Topics
- Bit manipulation, Combinatorics, Dynamic programming
- Solved
- No attempts yet
Problem
A non-empty set of non-negative integers is called perfect when it satisfies the following condition.
For any two integers and with and ( and may be equal), . Here is the bitwise exclusive or (XOR).
Given an integer , count the perfect sets whose every element is at most .
Input
The first line contains an integer ().
Output
Print on the first line the number of perfect sets whose every element is at most , modulo .
Notes
For the perfect sets are and , so there are two of them.
For they are , , , , and , so there are six of them.