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


+ Recent posts