ECOO '17 R3 P1 - Baker Brie

View as PDF

Submit solution

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

Problem type
Author: Andrew Seidel

Baker Brie is holding a celebration for being in business for 13 years, and having opened its 130^{th} 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 (13), 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 (13), then that franchise will receive a bonus.

Input Specification

The input will contain 10 datasets.

On the first line of each dataset there will be the values F and D separated by a space where F (4 \le F \le 130) represents the number of franchises that Baker Brie has, and D (2 \le D \le 4\,745) represents the number of days of information.

On the next D lines, there will be F integers separated by spaces (each in the range 1 through 13\,000), such that the i^{th} integer on line j represents the number of baked goods sold by franchise i on day j.

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 13. 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 2 cases are shown in this sample.

Explanation of Sample Output

In the first case, the first franchise sold a total of 26 baked goods (which is 2 baker's dozens), the second franchise sold a total of 13 baked goods (which is 1 baker's dozen), and finally, all franchises together sold 13 baked goods on the first day (which is 1 baker's dozen). This totals to 4 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 1 baker's dozen.

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org


Comments


  • 0
    ItzAyan  commented on Nov. 7, 2023, 3:47 p.m.

    Why is my code failing in test cases 2 and 3 even though I have supported multiple digit numbers


  • -3
    pyrus  commented on April 12, 2022, 6:46 p.m.

    Alright, need a hint. Why am I getting ValueError and TypeError in test cases 2 and 3, respectively?


    • 4
      Kirito  commented on April 13, 2022, 6:09 a.m.

      Consider what happens if F or D have more than 1 digit.


      • -2
        pyrus  commented on April 13, 2022, 6:57 a.m.

        Oh my god. Of course. And here I am deeply scrutinizing almost every other part of the code, assuming the part where I collect the variables must be correct. Thank you.