atcoder#ABC233C. [ABC233C] Product
[ABC233C] Product
Score : points
Problem Statement
We have bags. Bag contains balls. The -th ball in Bag has a positive integer written on it.
We will pick out one ball from each bag. How many ways are there to pick the balls so that the product of the numbers written on the picked balls is ?
Here, we distinguish all balls, even with the same numbers written on them.
Constraints
- The product of the numbers of balls in the bags is at most : .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
2 40
3 1 8 4
2 10 5
2
When choosing the -rd ball in Bag and -st ball in Bag , we have . When choosing the -nd ball in Bag and -nd ball in Bag , we have . There are no other ways to make the product , so the answer is .
3 200
3 10 10 10
3 10 10 10
5 2 2 2 2 2
45
Note that we distinguish all balls, even with the same numbers written on them.
3 1000000000000000000
2 1000000000 1000000000
2 1000000000 1000000000
2 1000000000 1000000000
0
There may be no way to make the product .