CF1487F.Ones
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a positive (greater than zero) integer n.
You have to represent n as the sum of integers (possibly negative) consisting only of ones (digits '1'). For example, 24=11+11+1+1 and 102=111−11+1+1.
Among all possible representations, you have to find the one that uses the minimum number of ones in total.
给你一个正整数 n(即大于零的整数)。
你需要将 n 表示为若干个整数(这些整数可以为负数)之和,且这些整数的每一位数字只能是 1(即形如 1, 11, 111, 1111, … 的数)。例如:24=11+11+1+1,以及 102=111−11+1+1。
在所有可能的表示方式中,你需要找出总共使用最少数量的数字 1 的那一种表示。
输入格式
The single line contains one integer n (1≤n<1050).
单行包含一个整数 n(1≤n<1050)。
输出格式
Print one integer x — the minimum number of ones, such that there exist a representation of n as the sum of integers (possibly negative) that uses x ones in total.
输出一个整数 x —— 表示将 n 表示为若干个整数(可以为负数)之和时,所需使用的数字 1 的最小总个数。
输入输出样例
输入#1
24
输出#1
6
输入#2
102
输出#2
7
输入解题思路,AI测评打分。不知道怎么写?