Watson and Digit Sums
All submissions for this problem are available.
Watson is going to play mind games with Sherlock. He gives an integer d to Sherlock.
Among all possible positive integers N having sum of digits d, consider the integer N+1, and find the minimum possible digit sum N+1 can have.
For example, if d = 9, then N could be 9, 18, 27, 36,711 and so on. However, if Sherlock chooses N = 9, then sum of digits of N + 1 i.e. 10 will be 1, which is the minimum possible.
First line of the input contains an integer T, the number of test cases.
The only line of each test case consists of an integer d.
For each test case output the required answer in one line.
- 1 ≤ T ≤ 100
- 1 ≤ d ≤ 100000
Input: 1 5 Output: 6
Possible value of N in given case are: 32,23,113,131 and so on, in each case digit sum of (N+1) would be 6.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.