#P9619. 生成树
生成树
Background
We are immature fighters, and we will never admit defeat now.
We are immature dreamers, and we will never cry now.
Problem Description
You are given an undirected complete graph and a weight array of length . represents the weight of the node with index .
Define the edge value of an edge as , where , i.e., the bitwise XOR of the weights of the two endpoints. Define the weight of a spanning tree of as , where , i.e., the sum of edge values on the tree.
You need to compute , i.e., the sum of the weights of all different spanning trees in .
We consider two spanning trees to be different if and only if their edge sets are not exactly the same, i.e., there exists at least one edge that belongs to exactly one of the two spanning trees.
Input Format
There are two lines.
The first line contains an integer , denoting , i.e., the number of nodes.
The second line contains integers, which are in order.
Output Format
Output one integer in one line, which is your answer modulo .
3
1 2 3
12
6
1 1 4 5 1 4
19008
10
1 1 4 5 1 4 1 9 1 9
567022588
Hint
Sample #1 Explanation:
Consider that there are three spanning trees in total: .
Their weights are , , and .
So .
Constraints
It is guaranteed that for all testdata, , . |Test Point ID|Constraints|Special Property| |:-:|:-:|:-:| |||All are equal.| |||| |||| |||| |||| ||||
Translated by ChatGPT 5