#BS0000182. Khôi phục giai thừa (Recover Factorial)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Khôi phục giai thừa (Recover Factorial)
Recover Factorial
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
For a non-negative integer , the factorial is the product of the positive integers from to , with by convention.
When factoring into primes, repeated prime factors are counted separately. For example,
so contains prime factors when multiplicity is counted.
Given a non-negative integer , find the smallest possible for which has exactly prime factors, counted with multiplicity.
If no such exists, output the specified impossibility message. For , the smallest answer is .
Input
- The only line contains a non-negative integer , the required number of prime factors in the factorial's prime factorization.
Output
- If exists, print exactly
Case 1: x!, replacingxwith the answer. - Otherwise print exactly
Case 1: Not possible.
The capitalization, spaces, colon, and exclamation mark must match these formats.
Subtasks
- Subtask 1 (20 points): ; is an integer.
- Subtask 2 (30 points): ; is an integer.
- Subtask 3 (50 points): ; is an integer.
Examples
Example 1
Input
4
Output
Case 1: 4!
Explanation
has one prime factor, has two, and has . The first factorial with exactly four prime factors is , so the output is Case 1: 4!.
Example 2
Input
240
Output
Case 1: 101!
Explanation
The factorization of contains prime factors with multiplicity. Because is prime, multiplying by adds exactly one factor, so has . The cumulative count increases for each , hence is the smallest answer.
Example 3
Input
241
Output
Case 1: Not possible
Explanation
has prime factors. Multiplying by adds three factors, taking the total directly to . Thus the count never equals , and the answer is Case 1: Not possible.