The factorial of a positive integer number N, denoted as N!, is defined as the product of all positiveinteger numbers smaller or equal to N. For example 4! = 4 × 3 × 2 × 1 = 24.
Given a positive integer number N, you have to write a program to determine the smallest numberk so that N = a1! + a2! + . . . + ak!, where every ai, for 1 ≤ i ≤ k, is a positive integer number.
Input
The input consists of several test cases. A test case is composed of a single line, containing one integernumber N (1 ≤ N ≤ 105).OutputFor each test case in the output your program must output the smallest quantity of factorial numberswhose sum is equal to N.
Sample Input
10
25
Sample Output
3
2
--------------------------------------------------------分割线----------------------------------------------------------------------------------
给你一个数n,问这个数拆成阶乘相加的形式,最少需要分解成多少个。
相当于对于每一个阶乘来说,都是一个物品,重量为阶乘的大小。价值为1。求最小的价值。
代码就不贴了。记得初始化问题,应该是为INF的。