Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class MySolution {
- private static int k = 0;
- private static List<Integer> v = new ArrayList<>();
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- int m = sc.nextInt();
- generate(n, m);
- }
- public static void generate(int n, int m)
- {
- if(v.size() == n)
- {
- k++;
- if(k == 6659) {
- printVector(v);
- }
- }
- else
- {
- for(int i = 1; i <= m; i++) {
- v.add(i);
- generate(n, m);
- v.remove(v.size() - 1);
- }
- }
- }
- private static void printVector(List<Integer> v)
- {
- v.forEach(s -> System.out.print(s + " "));
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement