전체 글

전체 글

    N과 M (11) 풀이

    문제 링크: https://www.acmicpc.net/problem/15665 백준 알고리즘 기초 2/2 510에서 11번째 - 15665번 N과 M (11)를 풀어보았다. 풀이: 파이썬의 경우 product을 쓰고, set을 써서 중복을 제거했다. C++ Python from itertools import product n,m=map(int,input().split()) arr=list(map(int,input().split())) arr.sort() res=list(set(product(arr,repeat=m))) res.sort() for i in res: for j in i: print(j,end=' ') print() Java

    N과 M (10) 풀이

    문제 링크: https://www.acmicpc.net/problem/15664 백준 알고리즘 기초 2/2 510에서 10번째 - 15664번 N과 M (10)를 풀어보았다. 풀이: 파이썬의 경우 combinations을 쓰고, set을 써서 중복을 제거했다. C++ Python from itertools import combinations n,m=map(int,input().split()) arr=list(map(int,input().split())) arr.sort() res=list(set(combinations(arr,m))) res.sort() for i in res: for j in i: print(j,end=' ') print() Java

    N과 M (9) 풀이

    문제 링크: https://www.acmicpc.net/problem/15663 백준 알고리즘 기초 2/2 510에서 9번째 - 15663번 N과 M (9)를 풀어보았다. 풀이: 파이썬의 경우 permutations을 쓰고, set을 써서 중복을 제거했다. C++ Python from itertools import permutations n,m=map(int,input().split()) arr=list(map(int,input().split())) res=list(set(permutations(arr,m))) res.sort() for i in res: for j in i: print(j,end=' ') print() Java

    N과 M (8) 풀이

    문제 링크: https://www.acmicpc.net/problem/15657 백준 알고리즘 기초 2/2 510에서 8번째 - 15657번 N과 M (8)를 풀어보았다. 풀이: 파이썬의 경우 combinations_with_replacement을 이용했다. C++ Python from itertools import combinations_with_replacement n,m=map(int,input().split()) arr=list(map(int,input().split())) arr.sort() res=combinations_with_replacement(arr,m) for i in res: for j in i: print(j,end=' ') print() Java

    N과 M (7) 풀이

    문제 링크: https://www.acmicpc.net/problem/15656 백준 알고리즘 기초 2/2 510에서 7번째 - 15656번 N과 M (7)를 풀어보았다. 풀이: 파이썬의 경우 product을 이용했다. C++ Python from itertools import product n,m=map(int,input().split()) arr=list(map(int,input().split())) arr.sort() res=product(arr,repeat=m) for i in res: for j in i: print(j,end=' ') print() Java

    N과 M (6) 풀이

    문제 링크: https://www.acmicpc.net/problem/15655 백준 알고리즘 기초 2/2 510에서 6번째 - 15655번 N과 M (6)를 풀어보았다. 풀이: 파이썬의 경우 combinations을 이용했다. C++ Python from itertools import combinations n,m=map(int,input().split()) arr=list(map(int,input().split())) arr.sort() res=combinations(arr,m) for i in res: for j in i: print(j,end=' ') print() Java

    N과 M (5) 풀이

    문제 링크: https://www.acmicpc.net/problem/15654 백준 알고리즘 기초 2/2 510에서 5번째 - 15654번 N과 M (5)를 풀어보았다. 풀이: 파이썬의 경우 permutations을 이용했다. C++ Python from itertools import permutations n,m=map(int,input().split()) arr=list(map(int,input().split())) arr.sort() res=permutations(arr,m) for i in res: for j in i: print(j,end=' ') print() Java

    N과 M (4) 풀이

    문제 링크: https://www.acmicpc.net/problem/15652 백준 알고리즘 기초 2/2 510에서 4번째 - 15652번 N과 M (4)를 풀어보았다. 풀이: 파이썬의 경우 combinations_with_replacement을 이용했다. C++ Python from itertools import combinations_with_replacement n,m=map(int,input().split()) arr=[i+1 for i in range(n)] res=combinations_with_replacement(arr,m) for i in res: for j in i: print(j,end=' ') print() Java