MINNUM - Minimum Number
Prana has given a number. Now she wonder what will be the maximum number of digits that the sum of these digits is equals to the given number. After thinking sometimes she laughed at herself, cause the number is infinite.
Now your task is to find the minimum number of digits that the sum of these digits is equals to the given number.
The input contain a single integer N ( 0 ≤ N ≤ 1031 ). The input is terminated by a line containing -1.
Output a single line the number of digits that the sum of the digits is equals to the given number. See the sample input/output for exact formatting.
For the first test case given number is 11. Some possible way to make 11 is
7+4=11 which costs 2 digits.
2+3+6=11 which costs 3 digits.
1+2+3+5=11 which costs 4 digits.
1+2+3+0+5=11 which costs 5 digits.
So, here first example costs the minimum number of digits which is 2.
Note: There are no extra new lines between different numbers.
Problem setter: Abu Sufian, Dept. of CSE
Bangladesh University of Business and Technology (BUBT)
Implemented within 2 mins, then noticed that Java wasn't allowed.... Lol
Elementary but tedious to get right, C is not Python! Tests are weak, for instance a file returning incorrectly 1000 (instead of 1002) to 9010 as input got accepted. The correct answer for 0 as input remains unclear (the valid answer is 0, not 1).Last edit: 2017-04-14 16:57:28
doing without big integer....really a workout!
if you are getting wa then do check for 92
Clarify 0 test case, cause right answer by problem statement is 1
good questin, implemented my bigint
Nice and easy one...
Very good question.... :)
test cases with answers:
Result for 0 is 0, as in you don't have to use any digits.