## ECOO '17 R3 P1 - Baker Brie

View as PDF

Points: 5 (partial)
Time limit: 30.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
##### 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.

#### Input Specification

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 .

#### Output Specification

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.

#### Sample Input

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

#### Sample Output

4
1

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