Testing Round 10
翻译中…
Prof. Vasechkin wants to represent positive integer $*n*$ as a sum of addends, where each addends is an integer number containing only 1s. For example, he can represent 121 as 121=111+11+–1. Help him to find the least number of digits 1 in such sum.
翻译中…
Input
翻译中…
The first line of the input contains integer $*n*$ ($1 ≤ *n* < 10^{15}$).
翻译中…
Output
翻译中…
Print expected minimal number of digits 1.
翻译中…
样例
Input #1
121
Output #1
6
InputCopy
OutputCopy
题目信息
标签
暴力
DFS 及类似
分治
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。