TORONTO KIDS COMPUTER CLUB | Markham Saturday 14:00 Java Homework 20.12.26.
18886

# Markham Saturday 14:00 Java Homework 20.12.26.

## 30 Dec Markham Saturday 14:00 Java Homework 20.12.26.

Question 1:
You have been asked to take a small icon that appears on the screen of a smart telephone and scale it up so it looks bigger on a regular computer screen.

The icon will be encoded as characters (x and *) in a 3 × 3 grid as follows:

*x*
xx
* *

Write a program that accepts a positive integer scaling factor and outputs the scaled icon. A scaling factor of k means that each character is replaced by a k × k grid consisting only of that character.

Input Specification
The input will be a positive integer k such that k < 25.

Output Specification
The output will be 3k lines, which represent each individual line scaled by a factor of k and repeated k times. A line is scaled by a factor of k by  replacing each character in the line with k copies of the character.

Sample Input
3

Output for Sample Input

***xxx***
***xxx***
***xxx***
xxxxxx
xxxxxx
xxxxxx
***   ***
***   ***
***   ***

Question 2:
You have been asked by a parental unit to do your chores.

Each chore takes a certain amount of time, but you may not have enough time to do all of your chores, since you can only complete one chore at a time. You can do the chores in any order that you wish.

What is the largest amount of chores you can complete in the given amount of time?

Input Specification
The first line of input consists of an integer T (0 ≤ T ≤ 100000), which is the total number of minutes you have available to complete your chores.

The second line of input consists of an integer C (0 ≤ C ≤ 100), which is the total number of chores that you may choose from. The next C lines contain the (positive integer) number of minutes required to do each of these chores. You can assume that each chore will take at most 100000 minutes.

Output Specification
The output will be the maximum number of chores that can be completed in time T.

Sample Input 1
6
3
3
6
3

Output for Sample Input 1
2

Explanation of Output for Sample Input 1
Chores must be completed in at most 6 minutes. There are 3 chores available. The first chore takes 3 minutes. The second chore takes 6 minutes. The third chore takes 3 minutes. The answer is 2 since only 2 of these chores can be completed in 6 minutes of time. Specifically, the first and last chore can be completed in the allowable time. It is not possible to complete all 3 chores in 6 minutes.

Sample Input 2
6
5
5
4
3
2
1

Output for Sample Input 2
3

Explanation of Output for Sample Input 2
Tasks 3, 4, and 5 can be completed in 6 minutes. It is not possible to complete more than 3 tasks in 6 minutes.

Question 3:
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}.