Given a number N. The task is to find the maximum possible value of SumOfDigits(A) + SumOfDigits(B) such that A + B = n (0<=A, B<=n).
Input: N = 35 Output: 17 35 = 9 + 26 SumOfDigits(26) = 8, SumOfDigits(9) = 9 So, 17 is the answer. Input: N = 7 Output: 7
Approach: The idea is to divide the number into two parts A and B such that A is in terms of 9 i.e. closest number to N and B = N-A. For example, N = 35, Smallest Number that is closest to 35 is 29.
- Divide a number into two parts
- Divide a big number into two parts that differ by k
- Divide number into two parts divisible by given numbers
- Find the number of ways to divide number into four parts such that a = c and b = d
- Count number of ways to divide a number in 4 parts
- Check if all digits of a number divide it
- Count digits in given number N which divide N
- Find count of digits in a number that divide the number
- Possible cuts of a number such that maximum parts are divisible by 3
- Sum and Product of digits in a number that divide the number
- Break a number such that sum of maximum divisors of all parts is minimum
- Divide an isosceles triangle in two parts with ratio of areas as n:m
- Minimum cuts required to divide the Circle into equal parts
- Maximum number of region in which N non-parallel lines can divide a plane
- Split a number into 3 parts such that none of the parts is divisible by 3
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.