-
9375. 패션왕 신해빈 ( 조합 공식의 중요성)코테 준비/Hash map 2023. 1. 5. 00:20
알몸을 제외한 모든 조합의 개수를 구하는 것이다.
공식을 옛날에 배웠었는데 공식을 모르면 못풀었을듯....
import sys from collections import defaultdict t=int(sys.stdin.readline()) for i in range(t): cloth_set=defaultdict(list) sum=1 n=int(sys.stdin.readline()) for j in range(n): cloth_name,cloth_kind=sys.stdin.readline().split() cloth_set[cloth_kind].append(cloth_name) for key in cloth_set: sum*=(len(cloth_set[key])+1) #각 옷 종류마다 (옷이름의 개수+1) 곱한것 #조합 공식 기억해두자! print(sum-1) #공집합(알몸) 빼기
'코테 준비 > Hash map' 카테고리의 다른 글
[프로그래머스] 오픈채팅방 (0) 2024.02.02 [백준] 1269. 대칭 차집합 (0) 2023.01.24 [백준] 10815. 숫자카드 (다시보기) (1) 2023.01.19 1620. 포켓몬 (17219. 비밀번호 찾기와 유사) (0) 2023.01.03 17219. 비밀번호 찾기 (딕셔너리 시간 단축) (0) 2022.12.29