Sushi Dinner
Time limit1sMemory limit1024 MB
Count pairs of subsets X and Y of {2, ..., n} where every x in X is coprime to every y in Y, modulo p.
- Level
Medium7 of 10
- Topics
- Number theory, Dynamic programming, Bit manipulation
- Solved
- No attempts yet
Problem
Compute the number of ways to choose two subsets such that there is no pair , where and are not relatively prime. The sets and may be empty. Output the number of ways modulo .
Input
The input contains the integer and the modulo , separated by a space.
Output
Output the number of ways to choose the subsets that satisfy the condition above.