## CCC '14 S1 - Party Invitation

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 256M

Problem type
##### Canadian Computing Competition: 2014 Stage 1, Junior #4, Senior #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 and place them in a list in this order. Then perform rounds. In each round, use a number to determine which friends to remove from the ordered list.

The rounds will use numbers . In round remove all the remaining people in positions that are multiples of (that is, ) The beginning of the list is position .

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

#### Input Specification

The first line of input contains the integer . The second line of input contains the integer , which is the number of rounds of removal. The next lines each contain one integer. The of these lines contains indicating that every person at a position which is multiple of 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 . 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 . After the second round of removals, we remove every 3rd remaining invitee: thus, we keep and , remove and keep and , which leaves us with an invitee list of .

• commented on Feb. 19, 2024, 8:04 p.m.

this took me way longer than expected

• commented on Feb. 3, 2024, 12:08 a.m.

buddy this is senior 1

• commented on Feb. 19, 2024, 8:56 p.m.

Canadian Computing Competition: 2014 Stage 1, Junior #4, Senior #1

So... actually thunder200911133 isn't wrong. it is both J4 and S1.

• commented on Feb. 21, 2024, 12:00 a.m.

holy nerd emoji

• commented on Feb. 19, 2024, 7:58 p.m. edited

fax

• commented on Jan. 29, 2024, 7:47 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on March 2, 2024, 12:02 a.m.

agreed

• commented on Feb. 12, 2024, 1:09 a.m.

is this sarcasm or something