logo AlgoBeat OnlineJudge
登录 注册

#216661. [GKS 2018 #A] Even Digits

内存限制:1024 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Supervin has a unique calculator. This calculator only has a display, a plus button, and a minus button. Currently, the integer is displayed on the calculator display.

Pressing the plus button increases the current number displayed on the calculator display by . Similarly, pressing the minus button decreases the current number displayed on the calculator display by . The calculator does not display any leading zeros. For example, if is displayed on the calculator display, pressing the minus button once will cause the calculator to display .

Supervin does not like odd digits, because he thinks they are "odd". Therefore, he wants to display an integer with only even digits in its decimal representation, using only the calculator buttons. Since the calculator is a bit old and the buttons are hard to press, he wants to use a minimal number of button presses.

Please help Supervin to determine the minimum number of button presses to make the calculator display an integer with no odd digits.

输入格式

The first line of the input gives the number of test cases, . test cases follow. Each begins with one line containing an integer : the integer initially displayed on Supervin's calculator.

输出格式

For each test case, output one line containing Case #x: y, where is the test case number (starting from ) and is the minimum number of button presses, as described above.

样例

样例输入 1

4
42
11
1
2018

样例输出 1

Case #1: 0
Case #2: 3
Case #3: 1
Case #4: 2

数据范围与提示

In Sample Case #1, the integer initially displayed on the calculator has no odd digits, so no button presses are needed.

In Sample Case #2, pressing the minus button three times will cause the calculator to display . There is no way to satisfy the requirements with fewer than three button presses.

In Sample Case #3, either pressing the minus button once (causing the calculator to display ) or pressing the plus button once will cause the calculator to display an integer without an odd digit.

In Sample Case #4, pressing the plus button twice will cause the calculator to display . There is no way to satisfy the requirements with fewer than two button presses.

Limits

.

Small dataset (Test set 1 - Visible)

.

Large dataset (Test set 2 - Hidden)

.