- (headgear + 1) * (eyewear + 1)으로 문제 해결
- (옷의 종류 + 1) * (...) * ...
첫 번째 예제의 경우,
(headgear) hat turban x
(eyewear) sunglasses x
x는 해당 종류를 입지 않는 것을 의미함.
모든 경우를 구하면 (3x2)-1, -1은 아무것도 입지 않는 경우 제외
n = int(input())
# test case
for _ in range(n):
_n = int(input())
# each case
clothes_type = {}
for _ in range(_n):
# 의류 이름과 종류
name, type = input().split()
# 의류 종류를 dict의 key로 사용
if(type in clothes_type):
clothes_type[type] += 1
else:
clothes_type[type] = 1
case = 1
# 옷의 종류 + 1
for key in clothes_type.keys():
case = case * (clothes_type[key] + 1)
print(case - 1)
'# 코딩 문제 관련 > 파이썬' 카테고리의 다른 글
백준 2004번(python) (0) | 2020.04.28 |
---|---|
백준 1676번(python) (0) | 2020.04.27 |
백준 11050번(python) (0) | 2020.04.19 |
백준 3036번(python) (0) | 2020.04.19 |
백준 2981번(python) (1) | 2020.04.18 |