public class Main {
public static void main(String[] args) throws IOException {
Queue<Integer> card = new LinkedList<>();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
for (int i = 1; i <= n; i++) {
card.offer(i);
}
while (card.size() != 1) {
card.poll();
card.offer(card.poll());
}
System.out.println(card.peek());
}
}
'Java > AlgorithmPS' 카테고리의 다른 글
프로그래머스) 기능개발 (0) | 2023.10.14 |
---|---|
백준) 큐(10845 번) (1) | 2023.10.13 |
프로그래머스) 올바른 괄호 (0) | 2023.10.05 |
백준) 균형잡힌 세상 (4949번) (0) | 2023.10.04 |
백준) 도키도키 간식드리미 (12789번) (0) | 2023.09.27 |