sm 기술 블로그
95. 1269(대칭 차집합) 본문
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
A = set(map(int, input().split()))
B = set(map(int, input().split()))
C = 0
C += len(list(A-B))
C += len(list(B-A))
print(C)
문제요약
A와B의 차집합, B와A의 차집합 개수를 구해라.
해설
집합에서 차집합,교집합,합집합에 관한 것을 문제로 다룬 것이다.
집합자료형은 아래를 참고하자.
https://smhope.tistory.com/257
집합자료형
집합이 다음과 같이 주어졌다고 해보자. >>> s1 = set([1, 2, 3, 4, 5, 6]) >>> s2 = set([4, 5, 6, 7, 8, 9]) 차집합 >>> s1.difference(s2) {1, 2, 3} >>> s2.difference(s1) {8, 9, 7} >>> s1 - s2 {1, 2, 3} >..
smhope.tistory.com
'문제 > 백준_파이썬' 카테고리의 다른 글
97. 1085(직사각형에서 탈출) (0) | 2022.06.21 |
---|---|
96. 11478(서로 다른 문자열의 개수) (0) | 2022.06.21 |
94. 1764(듣보잡) (0) | 2022.06.20 |
93. 10816(숫자 카드2) (0) | 2022.06.19 |
92. 1620(나는야 포켓몬 마스터 이다솜) (0) | 2022.06.19 |
Comments