조합과 순열
1. 조합 (Combination) 조합은 순서를 고려하지 않고 어떤 원소가 선택되었는지만 중요한 경우를 의미합니다. 반장 선거에 6명의 학생이 출마했고, 여기서 2명을 선출한다고 가정해봅시다. 첫 번째로 한 명 뽑는 경우 처음에 일단 한 명 먼저 뽑는다고 생각해볼게요. 그러면 이 때는 6명 중에서 아무나 1명 뽑으면 되...
1. 조합 (Combination) 조합은 순서를 고려하지 않고 어떤 원소가 선택되었는지만 중요한 경우를 의미합니다. 반장 선거에 6명의 학생이 출마했고, 여기서 2명을 선출한다고 가정해봅시다. 첫 번째로 한 명 뽑는 경우 처음에 일단 한 명 먼저 뽑는다고 생각해볼게요. 그러면 이 때는 6명 중에서 아무나 1명 뽑으면 되...
문제링크: https://school.programmers.co.kr/learn/courses/30/lessons/42895 코드 def solution(N, number): dp = [set() for _ in range(9)] # i개의 N으로 만들 수 있는 초기값 for i in range(1, 9): dp...
문제링크: https://www.acmicpc.net/problem/8979 코드 import sys n, k = map(int, sys.stdin.readline().rstrip().split()) b = [] for _ in range (n): a = list(map(int, sys.stdin.readline().rstrip().spl...
문제링크: https://school.programmers.co.kr/learn/courses/30/lessons/258709 코드 from itertools import combinations, product from bisect import bisect_left def solution(dice): n = len(dice) a = ...
문제 링크: https://school.programmers.co.kr/learn/courses/30/lessons/258711 코드 주석은 내가보려고 달아놓음 def solution(edges): answer = [0, 0, 0, 0] # edges는 이중리스트로 주어진다. # 이 문제에서 찾아야 할 건 그래프 안의 ...
문제링크: https://school.programmers.co.kr/learn/courses/30/lessons/67256 코드 def solution(numbers, hand): keypad = { 1: (0, 0), 2: (0, 1), 3: (0, 2), 4: (1, 0), 5: (1, 1), 6: (1, ...
문제링크: https://school.programmers.co.kr/learn/courses/30/lessons/64061 코드 def solution(board, moves): ans = [] removed = 0 for a in moves: col = a - 1 for row in r...
문제링크: https://www.acmicpc.net/problem/1926 코드 import sys from collections import deque n, m = map(int, sys.stdin.readline().rstrip().split()) draw = [] for _ in range(n): a = list(map(int, sy...
문제링크: https://school.programmers.co.kr/learn/courses/30/lessons/12909 코드 def solution(s): stack = [] for i in s: if i == '(': stack.append(i) elif i == ')'...
문제링크: https://school.programmers.co.kr/learn/courses/30/lessons/42888 코드 def solution(record): user_dict = {} log = [] for entry in record: data = entry.split() com...