NOI '15 P3 - Sushi Dinner

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem type

Compute the number of ways to choose two subsets X,Y{2,3,,n} such that there does not exist xX,yY such that x and y are not relatively prime. The sets X,Y may be empty. Output the number of ways modulo p.

Input Specification

The input contains the integer n and the modulo p separated by a space.

Output Specification

Output the number of ways to choose the subsets X,Y{2,3,,n} satisfying the condition above.

Sample Input 1

Copy
3 10000

Sample Output 1

Copy
9

Sample Input 2

Copy
4 10000

Sample Output 2

Copy
21

Sample Input 3

Copy
100 100000000

Sample Output 3

Copy
3107203

Constraints

Test CasenAdditional Constraints
12n300<p1000000000
2
3
42n100
5
62n200
7
82n500
9
10

Comments

There are no comments at the moment.