Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOJ] 11866 #29

Open
HyomK opened this issue May 15, 2023 · 0 comments
Open

[BOJ] 11866 #29

HyomK opened this issue May 15, 2023 · 0 comments

Comments

@HyomK
Copy link
Owner

HyomK commented May 15, 2023

백준 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;
            }
HyomK added a commit that referenced this issue May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant