Suppose you have a hyperintelligent bunny named Mr. Pummellord. With your help (and against all odds), Mr. Pummellord has started learning how to write numbers. He has already learned the first four digits: 1, 2, 3, and 4. But he does not yet realize that 4 is different than 1, so he thinks that 4 is just another way to write 1. It started out well, but he's still a bunny at the end of the day.
While running in his wheel, he keeps himself amused with a little game he created: he makes numbers with the four digits that he knows and sums their values. For example:
\(132 = 1 + 3 + 2 = 6\)
\(112314 = 1 + 1 + 2 + 3 + 1 + 1 = 9\)
Mr. Pummellord now wants to know how many such numbers he can create whose sum is a number \(n\). For \(n=2\), for example, he can make 5 numbers: 11, 14, 41, 44, and 2. (He knows how to count up beyond five, just not how to write it.) However, he cannot figure this out for \(n>2\) and asks for your help.
Input will consist of an arbitrary number of integers \(n\) such that \(1 \leq n \leq 1000\). You must read until you reach the end of file.
For each integer read, output a single integer on a line stating how many numbers Mr. Pummellord can make such that the sum of their digits is equal to n.
2
3
5
13
This is challenge 10198 of the ACM International Collegiate Programming Contest. Test input is provided by uDebug.
Please log in to submit your solution.
Difficulty 

Average test runtime  0.29 
Points (changes over time)  10 
Tried by  13 users 
Solved by  11 users 
#  Name  Runtime  Points worth 

1  Pascal  0.16  15 
2  贝尔恩德  0.16  15 
3  Chris Danger  0.17  14 
4  Mac  0.17  14 
5  ,s/java/NaN/gi  0.20  12 
6  JB  0.24  10 
7  Bjoern  0.25  9 
8  AlexanderP  0.26  9 
9  Thore  0.40  6 
10  IeM  0.52  4 
11  Skøgland  0.62  4 