-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoon2164.java
More file actions
31 lines (25 loc) · 750 Bytes
/
joon2164.java
File metadata and controls
31 lines (25 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package BaekJoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Deque;
import java.util.LinkedList;
public class joon2164 {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
Deque<Integer> que = new LinkedList();
for(int i = 1; i<= n; i++){
que.add(i);
}
while(true){
if(que.size() == 1) {
System.out.println(que.getLast());
break;
}
que.pop();
que.add(que.getFirst());
que.pop();
}
}
}