#P6570. [NOI Online #3 提高组] 优秀子序列
[NOI Online #3 提高组] 优秀子序列
Problem Description
Given a non-negative integer sequence of length . For a subsequence of , (, , same below), we call an excellent subsequence of if and only if the bitwise AND of any two different elements is , that is: for all , it holds that , where is the bitwise AND operation.
For the subsequence , we define its value as , where denotes the number of positive integers not greater than that are coprime to .
Now please compute the sum of values of all excellent subsequences of . Output the answer modulo .
Input Format
The first line contains a positive integer , denoting the length of the sequence.
The second line contains non-negative integers separated by spaces, denoting .
Output Format
Only one line with one integer, denoting the result of the answer modulo .
4
1 2 2 3
12
Hint
Explanation for Sample 1
The valid subsequences are: , , , , , , . Their values are , , , , , , , respectively, and the total sum is .
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- There is another of the testdata where it is guaranteed that .
- For of the testdata, it is guaranteed that and .
Translated by ChatGPT 5