File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ 7,3 <- input
3
+ 7 -> 전체 인원수
4
+ 3 -> 제거 순번
5
+
6
+ 큐로 뺐다가 넣으면 될듯
7
+ */
8
+
9
+ // 22:13
10
+
11
+ import java .io .*;
12
+ import java .util .*;
13
+
14
+ public class Boj1158 {
15
+
16
+ public static void main (String ...args ) throws Exception {
17
+ var br = new BufferedReader (new InputStreamReader (System .in ));
18
+ var sb = new StringBuilder ();
19
+
20
+ var queue = new LinkedList <Integer >();
21
+ var inputs = br .readLine ().split (" " );
22
+
23
+ var count = Integer .parseInt (inputs [0 ]); // 전체 인원수
24
+ var orderOfRemoval = Integer .parseInt (inputs [1 ]);// 제거 순번
25
+
26
+ // 초기화
27
+ for (int i = 1 ; i <= count ; i ++){
28
+ queue .add (i );
29
+ }
30
+
31
+ int repeatCount = 1 ;
32
+ while (queue .size () > 0 ){
33
+ var element = queue .poll ();
34
+
35
+ if (repeatCount ++ == orderOfRemoval ){
36
+ sb .append (element );
37
+ if (queue .size () != 0 ){
38
+ sb .append (", " );
39
+ }
40
+
41
+ repeatCount = 1 ;
42
+ continue ;
43
+ }
44
+
45
+ queue .add (element );
46
+ }
47
+
48
+ System .out .println (String .format ("<%s>" , sb ) );
49
+ }
50
+ }
You can’t perform that action at this time.
0 commit comments