#P3123. Cow Math Puzzle
Cow Math Puzzle
Cow Math Puzzle
Farmer John and Bessie the cow love exchanging puzzles. In this challenge, you are given the expression ((B+E+S+S+I+E)(G+O+E+S)(M+O+O)), which can be simplified to ((B+2E+2S+I)(G+O+E+S)(M+2O)). For each variable among (B, E, S, I, G, O, M), a list of possible integer values is provided. Your task is to count the number of ways to assign values to these variables so that the value of the expression is a multiple of 7. Note that because the answer can be very large, you should use 64-bit integers, where applicable.
inputFormat
The input consists of 7 lines, one for each variable in the order B, E, S, I, G, O, M. Each line begins with the variable letter, followed by an integer representing the number of possible values, and then that many integers. For example:
B 2 1 2 E 3 3 4 5 S 2 7 8 I 1 0 G 2 5 6 O 2 1 2 M 1 3
Note: The integers may be negative or positive.
outputFormat
Output a single integer representing the number of assignments for which the expression is a multiple of 7.
sample
B 2 1 2
E 2 3 4
S 2 5 6
I 2 7 8
G 2 9 10
O 2 11 12
M 2 13 14
0