#P7438. [2017年杭电多校]Expectation Division
[2017年杭电多校]Expectation Division
Expectation Division
Problem Description
To be frank with you, this problem is a classic problem of tremendous magnitude which may increase the difficulty of this problem. We define a type of operation concerning a positive integer as to replace it with an integer , one of factors of . You are given a positive integer and then we will ask you to determine the expectation number of times to utilize this type of operation if we want to change into by operating again and again, assuming each possible in each operation has equal possibility to select. For the sake of calculation, and all its distinct prime factors will be given, satisfying has distinct prime factors exactly.
Input
The input contains multiple test cases. For each test case: The first line contains two positive integers and which indicates is the number of distinct prime factors of , satisfying . The second lines contains distinct prime numbers , satisfying . About test cases in total. Warm Tips for C/C++: __int128_t is available here but standard solutions of this problem do not use this compiler-dependent data type.
Output
For each test case, output " Case #: " in one line (without quotes), where indicates the case number starting from and denotes the expectation number of times to utilize this type of operation of corresponding case. Your answer will be considered correct if its absolute or relative error won't exceed .
Sample Input
2 1
2
4 1
2
6 2
2 3
8 1
2
10 2
2 5
12 2
2 3
Sample Output
Case #1: 2.0000000000
Case #2: 2.5000000000
Case #3: 2.6666666667
Case #4: 2.8333333333
Case #5: 2.6666666667
Case #6: 3.0333333333
Source
2017 Multi-University Training Contest - Team 1