Problem F
Feeding the Herrings
Zookeper Willy is feeding herrings today. He is feeding them
to seals, as they are their preferred food. There are three
separate pools in which the seals live. The ZOO is a modern
institution and it demands their employees to keep track of
feeding habits of animals. There is a touchscreen installed at
the seals pools and Willy has to enter the number of herrings
which he is going to deposit into each of the three pools.
Unfortunately, the screen is not working properly - in
particular, it is impossible to enter the digit ‘
Willy called the chief marine mammals zookeper and asked for help.
“That is OK,” said the chief, “just distribute the herrings
in such a way that the number of herrings which go into each
pool does not contain the digit ‘
“But there is a lower limit
“You will be able to find a suitable division,” assured him the chief, “considering the numbers of herrings in the bucket, there should be zillions of possible divisions.”
“Well, exactly how many?” wondered Willy for himself.
You will be given the total number
Input
The first line contains
Output
For each test case print on a separate line the number of
possible divisions of the herrings into the three given pools.
Express the result modulo
Sample Input 1 | Sample Output 1 |
---|---|
4 3 1 4 1 7 2 99999 1 |
1 3 0 9521331 |