CF845B.Luba And The Ticket
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Luba has a ticket consisting of 6 digits. In one move she can choose digit in any position and replace it with arbitrary digit. She wants to know the minimum number of digits she needs to replace in order to make the ticket lucky.
The ticket is considered lucky if the sum of first three digits equals to the sum of last three digits.
输入格式
You are given a string consisting of 6 characters (all characters are digits from 0 to 9 ) — this string denotes Luba's ticket. The ticket can start with the digit 0 .
输出格式
Print one number — the minimum possible number of digits Luba needs to replace to make the ticket lucky.
输入输出样例
输入#1
000000
输出#1
0
输入#2
123456
输出#2
2
输入#3
111000
输出#3
1
说明/提示
In the first example the ticket is already lucky, so the answer is 0 .
In the second example Luba can replace 4 and 5 with zeroes, and the ticket will become lucky. It's easy to see that at least two replacements are required.
In the third example Luba can replace any zero with 3 . It's easy to see that at least one replacement is required.