#SP0000223. Đa tập có phép XOR nguyên tố (Prime XOR)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đa tập có phép XOR nguyên tố (Prime XOR)
Prime XOR
Source: HackerRank
Version: Phuoc Hung OJ Extended
Problem Statement
Penny has an array of integers. She chooses a sub-multiset of its elements, using a value no more often than it occurs. Two choices are the same multiset when every integer has the same multiplicity in both choices, regardless of which positions were chosen.
The bitwise XOR of a multiset is the XOR of all its selected values. The empty multiset has XOR and is not counted as prime.
Count the number of distinct multisets whose bitwise XOR is prime. Output the count modulo .
Input
The first line contains . The second line contains exactly integers .
Output
Print the count of distinct sub-multisets with prime XOR, modulo .
Subtasks
-
Subtask 1 (20 points): ; for every .
-
Subtask 2 (30 points): ; for every .
-
Subtask 3 (50 points): ; for every .
Examples
Input
3
3511 3671 4153
Output
4
Explanation
The input contains three different values. There are sub-multisets including the empty one. The valid multisets are , , , and . Their XOR values are respectively , all prime. The three size-two choices give (even and greater than ), while the empty choice gives . Exactly choices qualify.