#P3361. Cool loves maids
Cool loves maids
Description
Cool has now figured out the layout of the women’s dormitory. The dormitory consists of many buildings, which can be abstracted as a grid.
The places where Cool’s maids are located can be represented by real-valued coordinates. A maid is in building if and only if , , . The distance between two maids is defined if and only if both the row and column indices of one maid’s building are strictly less than those of the other maid’s building; in that case, their distance is the Manhattan distance between their own coordinates.
Now Cool wants to compile a big statistic: compute the sum of all distances among maids.
Input Format
To avoid spending too much time on reading due to large input files that cannot be uploaded, this problem uses a data generation scheme.
The input contains two lines:
- The first line contains an integer .
- The second line contains integers $\mathrm{rxa}, \mathrm{rxc}, \mathrm{rya}, \mathrm{ryc}, \mathrm{rza}, \mathrm{rzc}$.
All real numbers are generated as follows:
- Initialize .
- Repeat the following process:
- $x = (y \times \mathrm{rxa} + \mathrm{rxc}) \bmod \mathrm{rp}$;
- $y = (z \times \mathrm{rya} + \mathrm{ryc}) \bmod \mathrm{rp}$;
- $z = (x \times \mathrm{rza} + \mathrm{rzc}) \bmod \mathrm{rp}$.
Each time, the real number obtained is $(x \bmod 20) + (y \bmod 10) \div 10 + (z \bmod 10) \div 100$. .
The -th maid uses the -th generated real number as the -coordinate, and the -th generated real number as the -coordinate.
Output Format
Output a single real number on one line, representing the average of all distances among the maids, with decimal places.
6
3 5 7 11 13 17
17.52167
Hint
Constraints
For all testdata, it is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号