← 返回 google 的题目列表Count Four-Digit Numbers With Digit Sum S
类型:online_judge
google
Given a four-digit number in the range from 0 to 36, implement a function that returns the number of four-digit numbers whose digits sum up to S. Implement the function as follows: int solution(int S);.
Examples
For S = 35, possible numbers are 9988, 9998, 9899, 9999. The function should return 4.
For S = 4, possible numbers are 1003, 1021, 2020, 4000. The function should return 3.
Note
Assume the input S is an integer in the range [0, 36].
Example
Input
0