Write in python please

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Write in python please
X * CCC X * ECOO X GBaker x X
с
dmoj.ca/problem/eco017r3p1
OM::OJ PROBLEMS SUBMISSIONS
PROBLEMS SUBMISSIONS USERS CONTESTS ABOUT
Input Specification
Ⓒ Chege x M Inbox x
C Che X
82"F
C Write X
45
C Write X
ECOO '17 R3 P1 - Baker Brie
Author: Andrew Seidel
Baker Brie is holding a celebration for being in business for 13 years, and having opened its 130th 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!
Untit X
▬▬ Q Search
EL
G Write X
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.
Actua X
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 ≤ F≤130) represents the number of franchises that Baker Brie has, and D
(2≤ D≤ 4745) 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 ith 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
My O X
Copy
All su
Best s
Voting
✓ Poi
O Tim
Mer
> O
> Prob
Transcribed Image Text:X * CCC X * ECOO X GBaker x X с dmoj.ca/problem/eco017r3p1 OM::OJ PROBLEMS SUBMISSIONS PROBLEMS SUBMISSIONS USERS CONTESTS ABOUT Input Specification Ⓒ Chege x M Inbox x C Che X 82"F C Write X 45 C Write X ECOO '17 R3 P1 - Baker Brie Author: Andrew Seidel Baker Brie is holding a celebration for being in business for 13 years, and having opened its 130th 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! Untit X ▬▬ Q Search EL G Write X 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. Actua X 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 ≤ F≤130) represents the number of franchises that Baker Brie has, and D (2≤ D≤ 4745) 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 ith 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 My O X Copy All su Best s Voting ✓ Poi O Tim Mer > O > Prob
DM::OJ PROBLEMS SUBMISSIONS USERS CONTESTS ABOUT
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 multip
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
45
4324
3321
8 24 1
2243
9323
82″ F
42
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 c
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 tota
Q Search
10
Transcribed Image Text:DM::OJ PROBLEMS SUBMISSIONS USERS CONTESTS ABOUT 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 multip 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 45 4324 3321 8 24 1 2243 9323 82″ F 42 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 c 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 tota Q Search 10
Expert Solution
Step 1: Algorithm
  1. Initialize a loop that runs twice (for x in range(2)).

  2. Inside the loop, read two integers F and D from the input.

  3. Initialize two lists, summ and vec, both of length F, filled with zeros.

  4. Start a nested loop that runs D times.

    a. Read a list of integers f from the input.

    b. Initialize idx to 0.

    c. Iterate over the elements in the list f:

    i. Add the current element to the corresponding index in the summ list.

    ii. Increment idx by 1.

    d. Append the sum of the elements in list f to the vec list.

  5. Initialize a variable ans to 0.

  6. Iterate over the elements in the concatenation of lists vec and summ.

    a. If the current element is divisible by 13 (i.e., i % 13 == 0), add the integer division of the element by 13 to ans.

  7. Print the value of ans.

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education