Balance | Solution | Tests |
Gigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance.
It orders two arms of negligible weight and each arm's length is 15. Some hooks are attached to these arms and Gigel wants to hang up some weights from his collection of G weights (1<=G<=20) knowing that these weights have distinct values in the range 1..25. Gigel may droop any weight of any hook but he is forced to use all the weights.
Finally, Gigel managed to balance the device using the experience he gained at the National Olympiad in Informatics. Now he would like to know in how many ways the device can be balanced.
Task
Knowing the repartition of the hooks and the set of the weights write a program that calculates the number of possibilities to balance the device.
It is guaranteed that will exist at least one solution for each test case at the evaluation.
Input format
The input file BALANTA.IN has the following structure:
Output format
The output file BALANTA.OUT contains on the first line the number M representing the number of possibilities to poise the balance.
Constraints
Observation
The device is balanced if the sum of the products between the weights and their position is 0.
Example
BALANTA.IN |
2 4 -2 3 3 4 5 8 |
BALANTA.OUT |
2 |
TIME LIMIT: 1 second/test