308494: CF1530A. Binary Decimal

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Binary Decimal

题意翻译

#### 1、题目描述翻译 有一种数,叫做 `binary decimal`。这种数是十进制,但是每一位只能是 $0$ 或 $1$。 给你一个数,请问:至少多少个 `binary decimal` 之和等于这个数?一个 `binary decimal` 可以使用多次。 #### 2、输入格式翻译 第一行一个数 $t$($1\le t\le1000$),代表测试样例数量。 接下来 $t$ 行,每行一个数 $n$($1\le n\le10^9$),代表给出的数。 #### 3、输出格式翻译 对于每个测试样例,输出一行,代表问题的答案? Translated by [dengzijun](https://www.luogu.com.cn/user/387836)

题目描述

Let's call a number a binary decimal if it's a positive integer and all digits in its decimal notation are either $ 0 $ or $ 1 $ . For example, $ 1\,010\,111 $ is a binary decimal, while $ 10\,201 $ and $ 787\,788 $ are not. Given a number $ n $ , you are asked to represent $ n $ as a sum of some (not necessarily distinct) binary decimals. Compute the smallest number of binary decimals required for that.

输入输出格式

输入格式


The first line contains a single integer $ t $ ( $ 1 \le t \le 1000 $ ), denoting the number of test cases. The only line of each test case contains a single integer $ n $ ( $ 1 \le n \le 10^9 $ ), denoting the number to be represented.

输出格式


For each test case, output the smallest number of binary decimals required to represent $ n $ as a sum.

输入输出样例

输入样例 #1

3
121
5
1000000000

输出样例 #1

2
5
1

说明

In the first test case, $ 121 $ can be represented as $ 121 = 110 + 11 $ or $ 121 = 111 + 10 $ . In the second test case, $ 5 $ can be represented as $ 5 = 1 + 1 + 1 + 1 + 1 $ . In the third test case, $ 1\,000\,000\,000 $ is a binary decimal itself, thus the answer is $ 1 $ .

Input

题意翻译

#### 1、题目描述翻译 有一种数,叫做 `binary decimal`。这种数是十进制,但是每一位只能是 $0$ 或 $1$。 给你一个数,请问:至少多少个 `binary decimal` 之和等于这个数?一个 `binary decimal` 可以使用多次。 #### 2、输入格式翻译 第一行一个数 $t$($1\le t\le1000$),代表测试样例数量。 接下来 $t$ 行,每行一个数 $n$($1\le n\le10^9$),代表给出的数。 #### 3、输出格式翻译 对于每个测试样例,输出一行,代表问题的答案? Translated by [dengzijun](https://www.luogu.com.cn/user/387836)

加入题单

算法标签: