#P10500. Rainbow 的信号
Rainbow 的信号
Problem Description
After Freda invented the pager, Rainbow further improved the signal used by the pager to send messages.
Since we are now in the digital information age, the signal invented by Rainbow is represented by natural numbers.
To prevent the big bad guy VariantF from eavesdropping on the conversation between two people, Rainbow split the conversation into three parts: , , and , and encrypted them with three passwords , , and respectively.
Now Freda has received Rainbow's message, and her first task is to decrypt it.
Freda learned that the passwords for these three parts are computed as follows:
Among the numbers from , two numbers are chosen uniformly at random. If , swap .
Take out the numbers from the -th to the -th in the signal to form a sequence .
The password for part is the mathematical expectation of the sum of sequence . The sum is the value obtained by applying XOR to all numbers in . The expectation of the sum is the average of the sums over all possible choices of .
The password for part is the expected value of the sum of sequence , defined similarly to the sum.
The password for part is the expected value of the sum of sequence , defined similarly to the sum.
Please help compute these three passwords.
Input Format
The first line contains a positive integer .
The second line contains natural numbers, representing the signal received by Freda.
Output Format
Output one line with three real numbers, representing the expected values of the sum, the sum, and the sum, respectively. Round to decimal places. Separate adjacent numbers with one space.
2
4 5
2.750 4.250 4.750
Hint
Sample Explanation
Sample 1 contains four possible choices of in total:
| sum | sum | sum | |
|---|---|---|---|
Each pair has the same probability of occurring, so taking the average of the sum, the sum, and the sum gives their mathematical expectation.
Constraints
For of the testdata, .
For of the testdata, .
For another of the testdata, the numbers are or .
For of the testdata, , and each of the natural numbers is at most .
Translated by ChatGPT 5