Number Theory
시간 제한7초메모리 제한1024 MB
n을 1, 11, 111, ... 꼴의 수들의 정수 계수 결합으로 나타낼 때 가중 합 i*|x_i|의 최솟값을 구해 출력한다.
문제
Let be the number which consists of ones in its decimal representation.
Bobo has an integer . Find a sequence of possibly negative integers where
- ,
- is minimized.
입력
The input consists of several test cases terminated by end-of-file. For each test case,
The first line contains an integer .
출력
For each test case, output an integer which denotes the minimum value of .
제한
- In each input, the sum of the number of decimal digits of does not exceed .
힌트
For the first test case, , . The minimum value is .
For the second test case, , , , . The minimum value is .