Binary Decimal solution codeforces
Let’s call a number a binary decimal if it’s a positive integer and all digits in its decimal notation are either or . For example, is a binary decimal, while and are not.
Given a number, you are asked to represent 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( ), denoting the number of test cases.
The only line of each test case contains a single integer( ), denoting the number to be represented.
For each test case, output the smallest number of binary decimals required to representas a sum.
3 121 5 1000000000
2 5 1
In the first test case,can be represented as or .
In the second test case,can be represented as .
In the third test case,is a binary decimal itself, thus the answer is .
Also read : Wafa Na Raas Aayi Lyrics