I I U C O N L I N E C O N T E S T 2 0 0 8 |
|
Problem J: Digit Blocks |
|
Input: standard input Output: standard output |
|
|
|
|
|
Input |
|
Input file contains at most 501 lines of inputs. Each line contains a string which contains only digits of hexadecimal number system (but will not contain zero). These digits denote the blocks that are available. For example if the string is “A1BBB5”, then you have two assume that total six blocks are available. Of them three blocks have shape of B, one block has shape of A, another block has shape of 1 and the last one has shape of 5. The string can be at most 16 characters long.
Input is terminated by a line containing a single ‘#’.
|
|
Output |
|
For each line of input produce one line of output. This line contains a decimal integer number which denotes the value N. Here N is the number of hexadecimal multiples of 5 that can be formed using the given digits. Note that you can use some or all of the given digits to form number. You can safely assume that N will fit in a 64 bit signed integer.
|
|
Sample Input |
Output for Sample Input |
A1BBB5 B
# |
4 0 |
|
|
Problem setter: Shahriar Manzoor Special thanks: Derek Kisman |