304418: CF845B. Luba And The Ticket

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Luba And The Ticket

题意翻译

## 题目描述 : Luba 有一张票,上有六个数字。每一次操作时,她可以将其中一个数字改为任意一个数字。现在她希望知道最少需要操作多少次才可以将这张票上的数字改为一个幸运数字。 当一个数的前三位之和与其后三位之和相等时,这便是一个幸运数字 ## 输入格式: 输入一个六位的字符串(字符串中的每一个字符均为0~9中的一个数字)作为Luba票上的数字。 **这组数字可以以0开头** ## 输出格式: 一个数字,即为使该票号成为幸运数字的最少操作次数 ## 说明: 样例1给出的数字本身即为幸运数字,因此操作数为 0 次 样例 2 中仅需将 4、5 替换成 0 即可,很容易便看出最少需要操作 2 次 样例 3 中仅需将任意一个 0 替换成 3,最少操作次数便是 1 *以上即为题目简述,有不足之处请大家指出*

题目描述

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.

Input

题意翻译

## 题目描述 : Luba 有一张票,上有六个数字。每一次操作时,她可以将其中一个数字改为任意一个数字。现在她希望知道最少需要操作多少次才可以将这张票上的数字改为一个幸运数字。 当一个数的前三位之和与其后三位之和相等时,这便是一个幸运数字 ## 输入格式: 输入一个六位的字符串(字符串中的每一个字符均为0~9中的一个数字)作为Luba票上的数字。 **这组数字可以以0开头** ## 输出格式: 一个数字,即为使该票号成为幸运数字的最少操作次数 ## 说明: 样例1给出的数字本身即为幸运数字,因此操作数为 0 次 样例 2 中仅需将 4、5 替换成 0 即可,很容易便看出最少需要操作 2 次 样例 3 中仅需将任意一个 0 替换成 3,最少操作次数便是 1 *以上即为题目简述,有不足之处请大家指出*

加入题单

算法标签: