TORONTO KIDS COMPUTER CLUB | PMCA Sunday 12:00 Python Homework 20.12.27.
18888

# PMCA Sunday 12:00 Python Homework 20.12.27.

## 30 Dec PMCA Sunday 12:00 Python Homework 20.12.27.

Question 1:
You are hosting a party and do not have room to invite all of your friends. You use the following unemotional mathematical method to determine which friends to invite.

Number your friends 1,2,…,K and place them in a list in this order. Then perform m rounds. In each round, use a number to determine which friends to remove from the ordered list.

The rounds will use numbers r1,r2,…,rm. In round i remove all the remaining people in positions that are multiples of ri (that is, ri,2ri,3ri,…) The beginning of the list is position 1.

Output the numbers of the friends that remain after this removal process.

Input Specification
The first line of input contains the integer K (1≤K≤100). The second line of input contains the integer m (1≤m≤10), which is the number of rounds of removal. The next m lines each contain one integer. The ith of these lines (1≤i≤m) contains ri (2≤ri≤100) indicating that every person at a position which is multiple of ri should be removed.

Output Specification
The output is the integers assigned to friends who were not removed. One integer is printed per line in increasing sorted order.

```Sample Input
10
2
2
3

Output for Sample Input
1
3
7
9

Explanation of Output for Sample Input
Initially, our list of invitees is {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}.
There will be two rounds of removals. After the first round of removals,
we remove the even positions (i.e., every second position),
which causes our list of invitees to be {1, 3, 5, 7, 9}.
After the second round of removals, we remove every 3rd remaining invitee:
thus, we keep 1 and 3, remove 5 and keep 7 and 9, which leaves us with an invitee list of {1, 3, 7, 9}.```

Question 2:
Annie has two favourite baseball teams: the Eagle and the Warrior. She has followed them throughout the season, which is now over. The season lasted for N days. Both teams played exactly one game on each day.

For each day, Annie recorded the number of runs scored by the Eagle on that day. She also recorded this information for the Warrior.

She would like you to determine the largest integer K such that K ≤ N and the Eagle and the Warrior had scored the same total number of runs K days after the start of the season. The total number of runs scored by a team after K days is the sum of the number of runs scored by the team in all games before or on the K-th day.

For example, if the Eagle and the Warrior have the same total number of runs at the end of the season, then you should output N. If the Eagle and the Warrior never had the same number of runs after K games, for any value of K ≤ N, then output 0.

Input Specification
The first line of input will contain an integer N (1 ≤ N ≤ 100 000). The second line will contain N space-separated non-negative integers representing the number of runs scored by the Eagle on each day, in order. The third line will contain N space-separated non-negative integers representing the number of runs scored by the Warrior on each day, in order. You may assume that each team scored at most 20 runs in any single game.
For 7 of the 15 points available, N ≤ 1000.

Output Specification
Output the largest integer K such that K ≤ N and the Eagle and the Warrior have the same total number of runs after K days.

```Sample Input 1
3
1 3 3
2 2 6

Output for Sample Input 1
2

Explanation for Output for Sample Input 1
After 2 days, each team had scored a total of 4 runs.````

```Sample Input 2
3
1 2 3
4 5 6

Output for Sample Input 2
0

Explanation for Output for Sample Input 2
The only time when the Eagle and the Warrior had scored the same number of runs was the beginning of the season.```

```Sample Input 3
4
1 2 3 4
1 3 2 4

Output for Sample Input 3
4

Explanation for Output for Sample Input 3
The Eagle and Warrior have the same number of total runs after the first game,
and after the third game, and after the fourth game.
We take the largest of these values (1, 3 and 4) and output 4.```

Question 3:
Eric works in a door mat manufacturing company. One day, he designed a new door mat with the following specifications:
◦ Mat size must be A x B. (A is an odd natural number, and B is 3 times A.)
◦ The design should have ‘WELCOME’ written in the center.
◦ The design pattern should only use |, . and – characters.

Sample Designs
Input:
7 x 21

output:

input:
11 x 33

Output: