Category
Similar Problems
0461. The number of ones
Time limit : 1000 ms
Memory limit : 64 mb
In arithmetic expression you are
allowed to use the number 1, operations of addition,
multiplication and parenthesis. What is the minimum number of ones you need
to obtain the positive integer n? |
|||||||||
Input: One number n (1 ≤ n ≤ 5000). |
|||||||||
Output: The
required number of ones. |
|||||||||
|
|||||||||
Example tip: (1 + 1 + 1) * (1 + 1) + 1 = 7 |
|||||||||
|