Author: Andrew Seidel
Baker Brie is holding a celebration for being in business for years, and having opened its franchise. Baker Brie wants to congratulate franchises that have performed well throughout the years. Baker Brie also wants to congratulate everyone for performing well on certain days of the year!
Baker Brie wants to offer congratulations as follows:
- If, in a single day, all franchises combined sell an amount of baked goods that is equivalent to a multiple of a baker's dozen , then all franchises will receive a bonus.
- If an individual franchise, throughout its entire existence, has sold an amount of baked goods that is equivalent to a multiple of a baker's dozen , then that franchise will receive a bonus.
The input will contain datasets.
On the first line of each dataset there will be the values and separated by a space where represents the number of franchises that Baker Brie has, and represents the number of days of information.
On the next lines, there will be integers separated by spaces (each in the range through ), such that the integer on line represents the number of baked goods sold by franchise on day .
You must determine, both for each day (across all franchises) and for each franchise (across all days), whether or not the number of baked goods sold is a multiple of . If it is, you need to track how many baker's dozens were sold. Report the total number of baker's dozens as a single integer on its own line.
4 5 4 3 2 4 3 3 2 1 8 2 4 1 2 2 4 3 9 3 2 3 4 2 4 4 4 1 1 1 3 4
Note: Only cases are shown in this sample.
Explanation of Sample Output
In the first case, the first franchise sold a total of baked goods (which is baker's dozens), the second franchise sold a total of baked goods (which is baker's dozen), and finally, all franchises together sold baked goods on the first day (which is baker's dozen). This totals to baker's dozens.
For the second dataset, no franchises made enough baked goods on their own, but there was a single baker's dozen created among them all on the first day. This totals to baker's dozen.
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org