1’s For All
시간 제한15초메모리 제한1024 MB
100000 이하의 각 n에 대해 1, 덧셈, 곱셈, 괄호, 자릿수 이어붙이기를 사용해 n을 만드는 데 필요한 1의 최소 개수를 구한다.
문제
The complexity of an integer is the minimum number of 's needed to represent it using only addition, multiplication and parentheses. For example, the complexity of is (writing as ) and the complexity of is (writing as ). We'll modify this definition slightly to allow the concatenation operation as well. This operation (which we'll represent using ©) takes two integers and "glues" them together, so © becomes the four digit number . Using this operation, the complexity of is now (writing it either as © or ©). Note that the concatenation operation ignores any initial zeroes in the second operand: © does not result in but results in .
We'll give you guess what the object of this problem is.
입력
Each test case consists of a single line containing an integer , where .
출력
Output the complexity of the number, using the revised definition above.