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 32 33 | package n1158; import java.util.Scanner; import java.util.Queue; import java.util.LinkedList; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = 0; int m = 0; n = sc.nextInt(); m = sc.nextInt(); Queue<Integer> q = new LinkedList<Integer>(); for(int i = 1; i<=n; i++){ q.offer(i); } System.out.print("<"); for(int i = 0; i < n - 1; i++){ for(int j = 0; j < m - 1; j++){ q.offer(q.poll()); } System.out.print(Integer.toString(q.poll()) + ", "); } System.out.print(Integer.toString(q.poll()) + ">"); } } | cs |
'알고리즘 > 백준 알고리즘' 카테고리의 다른 글
[code.plus 알고리즘 기초] no. 11727 (0) | 2019.01.17 |
---|---|
[code.plus 알고리즘 기초] no. 11726 (0) | 2019.01.16 |
[code.plus 알고리즘 기초]no. 1463 (0) | 2019.01.16 |
[code.plus 알고리즘 기초]no. 10799 (0) | 2019.01.13 |
[code.plus 알고리즘 기초]no. 9012 (0) | 2019.01.13 |