Time Limit: 0.5 second(s) | Memory Limit: 32 MB |
Given an integer n, you have to find whether it can be expressed as summation of factorials. For given n, you have to report a solution such that
n = x_{1}! + x_{2}! + ... + x_{n}! (x_{i} < x_{j} for all i < j)
Input starts with an integer T (≤ 10000), denoting the number of test cases.
Each case starts with a line containing an integer n (1 ≤ n ≤ 10^{18}).
For each case, print the case number and the solution in summation of factorial form. If there is no solution then print 'impossible'. There can be multiple solutions, any valid one will do. See the samples for exact formatting.
Sample Input |
Output for Sample Input |
4 7 7 9 11 |
Case 1: 1!+3! Case 2: 0!+3! Case 3: 1!+2!+3! Case 4: impossible |
Be careful about the output format; you may get wrong answer for wrong output format.
Developed and Maintained by
JANE ALAM JAN |
Copyright © 2012
LightOJ, Jane Alam Jan |