← 返回 cisco 的题目列表Count Numbers with Digits Sum
类型:online_judge
Given an integer X, write an algorithm to find the number of integers which are less than or equal to X and whose digits add up to Y.
Input Description: The first line of input consists of an integer - inputNum1, representing the given number X. The next line consists of an integer - inputNum2, representing the given number Y.
Output Description: Print the count of numbers whose digits add up to Y for the given number X.
Note: If no numbers are found whose digits add up to Y for the given number X, then print -1.
Example: Input: 20 5 Output: 2
Example
Input
20
5