-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
백준 11866 요세푸스 문제 0
[문제유형] 자료구조
https://www.acmicpc.net/problem/11866
주요 로직
ArrayList<Integer> persons = new ArrayList();
int cur = K - 1;
while (persons.size() > 1) {
builder.append(persons.get(cur).toString()+", ");
persons.remove(cur);
int cnt = 0;
int pos = cur - 1;
while (cnt < K) { // K 만큼 움직인다
cnt++;
// 범위를 벗어나면 다시 0으로 pos 를 옮긴다
if (pos >= persons.size() - 1) {
pos = 0;
} else pos++;
}
cur = pos;
}Metadata
Metadata
Assignees
Labels
No labels