RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 R03689

S1. Party Invitation

설명

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,\ldots,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 \(r_1, r_2,\ldots, r_m\). In round \(i\) remove all the remaining people in
positions that are multiples of \(r_i\)
(that is, \(r_i, 2r_i, 3r_i, \ldots\))
The beginning of the list is position 1.

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

제약
입력 형식

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

출력 형식

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

예제 1
입력
10
2
2
3
출력
1
3
7
9
설명

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\).

문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2014 Senior

평가 및 의견

S1. Party Invitation

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

S1. Party Invitation

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8