Computer Science/백준 알고리즘
[백준] 1182번 부분수열의 합 (파이썬)
roytravel
2022. 3. 11. 01:23
import sys
from itertools import combinations
input = sys.stdin.readline
N, S = list(map(int, input().split()))
nums = list(map(int, input().split()))
cnt = 0
for i in range(1, len(nums)+1):
result = combinations(nums, i)
for num in result:
if (sum(num) == S):
cnt += 1
print (cnt)
합이 S만 되면 되기 때문에 순서성이 필요 없는 조합을 사용.