[백준] #9375 패션왕 신해빈 python
2023. 1. 3. 16:32
https://www.acmicpc.net/problem/9375
9375번: 패션왕 신해빈
첫 번째 테스트 케이스는 headgear에 해당하는 의상이 hat, turban이며 eyewear에 해당하는 의상이 sunglasses이므로 (hat), (turban), (sunglasses), (hat,sunglasses), (turban,sunglasses)로 총 5가지 이다.
www.acmicpc.net
📕 설명 📕
경우의 수를 활용하여,
(종류의 수 + 1) * (종류의 수 + 1) * ... - 1
로 계산한다.
한 가지 빼는 경우는 알몸인 경우이다.
🧑🏻💻 나의 풀이 🧑🏻💻
from collections import Counter
T = int(input())
for _ in range(T):
N = int(input())
N_dict = {}
for i in range(N):
cloth, kinds = map(str,input().split())
if kinds not in N_dict:
N_dict[kinds] = [cloth]
else:
N_dict[kinds].append(cloth)
result = 1
for i in N_dict:
result *= len(N_dict[i]) + 1
print(result - 1)
'Programming > Algorithm' 카테고리의 다른 글
[백준] #2004 조합 0의 개수 python (0) | 2023.01.05 |
---|---|
[백준] #1676 팩토리얼 0의 개수 python (0) | 2023.01.04 |
[백준] #1010 다리 놓기 python (1) | 2023.01.02 |
[백준] #11051 이항 계수 2 python (0) | 2023.01.02 |
[백준] #11050 이항 계수 1 python (0) | 2023.01.02 |