#P9380. [THUPC 2023 决赛] 总投票数
[THUPC 2023 决赛] 总投票数
Background
Dear players of La Lumière: Scarlet Intense Flame - Adventurous Scarlet -:
It has been a great honor to spend these four wonderful years with you. We sincerely thank everyone for your support and companionship.
Now, we regret to announce that La Lumière: Scarlet Intense Flame - Adventurous Scarlet - will stop operating at 15:00 on May 28, 2023.
The shutdown schedule is as follows:
……
Problem Description
Before the shutdown, the operators launched a series of polls to find out which game content left a deeper impression on players.
As a loyal player of the series, you want to know how many people participated in the polls before the shutdown. However, the operators only made the final poll results public: for a poll with options, the proportion of players who chose option is (). When publishing the results, the operators rounded the numbers, and each is kept to the -th digit after the decimal point. Suppose in reality there are players participating in the poll, and players chose option . Then we should have
$$P_i-\frac{1}{2}\times 10^{-L}\le\frac{D_i}{K}< P_i+\frac{1}{2}\times 10^{-L}$$Clearly, all must be non-negative integers, and must be a positive integer. Now, given and , please find the smallest total number of votes such that has a non-negative integer solution.
Input Format
The first line contains a positive integer , indicating the total number of options in the poll. It is guaranteed that .
The next lines each contain a real number in , indicating the proportion of players who chose option . It is guaranteed that . All are kept to the -th digit after the decimal point, and .
Output Format
Output a positive integer, indicating the minimum total number of votes that satisfies the requirements.
3
0.166667
0.333333
0.500000
6
7
0.041096
0.109589
0.109589
0.164384
0.301370
0.068493
0.205479
73
13
0.00155
0.03876
0.01584
0.05189
0.08099
0.06825
0.15658
0.10404
0.02640
0.14332
0.12941
0.15529
0.02768
7766
Hint
[Sample Explanation #1]
The minimum total number of votes is , and the corresponding votes for each option are .
[Sample Explanation #2]
The minimum total number of votes is , and the corresponding votes for each option are .
[Sample Explanation #3]
The minimum total number of votes is , and the corresponding votes for each option are $12, 301, 123, 403, 629, 530, 1216, 808, 205, 1113, 1005, 1206, 215$.
[Constraints]
For all testdata, , , , and all are kept uniformly to at most digits after the decimal point.
[Source]
From the finals of the 2023 Tsinghua University Programming Contest and Collegiate Invitational (THUPC2023).
Solutions and other resources can be found at https://github.com/THUSAAC/THUPC2023.
Translated by ChatGPT 5