Problem - B - Codeforces
Problem - B - Codeforces
|
QuanVanHoang | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
You are given a positive integer n that does not contain leading zeros. You can remove any Language: Python 3.13.2
Almost always, if you send a solution
number of digits from the number n (including none) so that the remaining number contains at on PyPy, it works much faster
least one digit and is strictly greater than zero. The remaining digits cannot be rearranged. As Choose
Chọn tệp Không có …được chọn
a result, you may end up with a number that has leading zeros. file:
For example, you are given the number 103554. If you decide to remove the digits 1, 4, and one Submit
digit 5, you will end up with the number 035, whose cost is
035
= 4.375 .
0+3+5
What is the minimum number of digits you need to remove from the number so that its cost
becomes the minimum possible?
Input
The first line contains an integer t (1 ≤ t ≤ 1000 ) — the number of test cases.
100
The only line of each test case contains a positive integer n (1 ≤ n < 10 ) without leading
zeros.
Output
For each test case, output one integer on a new line — the number of digits that need to be
removed from the number so that its cost becomes minimal.
Example
input Copy
4
666
13700
102030
7
output Copy
2
4
3
0
Supported by
https://codeforces.com/contest/2093/problem/B 1/2