PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000182. Khôi phục giai thừa (Recover Factorial)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

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 xx, the factorial x!x! is the product of the positive integers from 11 to xx, with 0!=10!=1 by convention.

When factoring x!x! into primes, repeated prime factors are counted separately. For example,

4!=24=2⋅2⋅2⋅3,4!=24=2\cdot2\cdot2\cdot3,

so 4!4! contains 44 prime factors when multiplicity is counted.

Given a non-negative integer NN, find the smallest possible xx for which x!x! has exactly NN prime factors, counted with multiplicity.

If no such xx exists, output the specified impossibility message. For N=0N=0, the smallest answer is x=0x=0.

Input

  • The only line contains a non-negative integer NN, the required number of prime factors in the factorial's prime factorization.

Output

  • If xx exists, print exactly Case 1: x!, replacing x with 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): 0≤N≤10000\le N\le 1000; NN is an integer.
  • Subtask 2 (30 points): 0≤N≤1000000\le N\le 100000; NN is an integer.
  • Subtask 3 (50 points): 0≤N≤100000010\le N\le 10000001; NN is an integer.

Examples

Example 1

Input

4

Output

Case 1: 4!

Explanation

2!=22!=2 has one prime factor, 3!=6=2⋅33!=6=2\cdot3 has two, and 4!=24=23⋅34!=24=2^3\cdot3 has 3+1=43+1=4. The first factorial with exactly four prime factors is 4!4!, so the output is Case 1: 4!.

Example 2

Input

240

Output

Case 1: 101!

Explanation

The factorization of 100!100! contains 239239 prime factors with multiplicity. Because 101101 is prime, multiplying by 101101 adds exactly one factor, so 101!101! has 240240. The cumulative count increases for each x≥2x\ge2, hence 101101 is the smallest answer.

Example 3

Input

241

Output

Case 1: Not possible

Explanation

101!101! has 240240 prime factors. Multiplying by 102=2⋅3⋅17102=2\cdot3\cdot17 adds three factors, taking the total directly to 243243. Thus the count never equals 241241, and the answer is Case 1: Not possible.