Represent a number as the sum of positive numbers
ending with 9
Given an integer N, the task is to check if N can be
expressed as a sum of integers having 9 as the last digit
(9, 19, 29, 39...), or not. If found to be true, then find the
minimum count of such integers required to obtain N.
Otherwise print -1.
Examples:
Input: N = 156
Output: 4
Explanation:
156 = 9 + 9 + 9 + 129
Input: N = 60
Output: -1
Explanation:
No possible way to obtain sum 60 from numbers having
9 as the last digit.
Answers
Answered by
0
Answer:
Represent a number as the sum of positive numbers ending with 9
Last Updated: 04-09-2020
Given an integer N, the task is to check if N can be expressed as a sum of integers having 9 as the last digit (9, 19, 29, 39…), or not. If found to be true, then find the minimum count of such integers required to obtain N. Otherwise print -1.
Examples:
Input: N = 156
Output: 4
Explanation:
156 = 9 + 9 + 9 + 129
Input: N = 60
Output: -1
Explanation:
No possible way to obtain sum 60 from numbers having 9 as the last digit.
Similar questions