Guards
Time limit2sMemory limit32 MB
Count the subsets of at least two applicants with pairwise coprime favorite numbers, modulo 1,000,000,007.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Number theory, Combinatorics
- Solved
- No attempts yet
Problem
Sangsu bought a huge house yesterday. He advertised for guards to watch it, n people applied, and he numbered the applicants 1 to n.
Applicant i has a favorite number , which is a positive integer. When applicants i and j stand guard together and the greatest common divisor of and is 2 or more, the two feel close, talk all night, and fail to watch the house.
Sangsu hires at least 2 applicants, and he wants every pair among the hired applicants to have favorite numbers whose greatest common divisor is 1. Count how many ways he can hire. Two ways are different when the sets of hired numbers are different. Two applicants with the same favorite number are different people, but they cannot be hired together, because their greatest common divisor equals that number and is at least 2.
Input
The first line has the number of applicants n. ()
The second line has in order, separated by spaces. ()
Output
Print the number of ways to hire, taken modulo 1,000,000,007().