[原创]UVA 10780 Again Prime? No Time. [质因子分解]【数论】

2016-07-02 16:42:00 Tabris_ 阅读数：328

https://blog.csdn.net/qq_33184171/article/details/51811570

The problem statement is very easy. Given a number n you have to determine the largest power of m,
not necessarily prime, that divides n!.
Input
The input file consists of several test cases. The first line in the file is the number of cases to handle.
The following lines are the cases each of which contains two integers m (1 < m < 5000) and n
(0 < n < 10000). The integers are separated by an space. There will be no invalid cases given and
there are not more that 500 test cases.
Output
For each case in the input, print the case number and result in separate lines. The result is either an
integer if m divides n! or a line ‘Impossible to divide’ (without the quotes). Check the sample input
and output format.
Sample Input
2
2 10
2 100
Sample Output
Case 1:
8
Case 2:
97

Pi表示第i个质数的贡献是多少

8 = 2^3 ，Pi=3；

N! ~~ Pn1…Pn2…Pn3…Pn4…Pn5…
M ~~ Pm1…Pm2…Pm3…Pm4…Pm5…