BOJ - 1182 - 부분수열의 합
Updated:
import sys
def DFS(S, dataArray, count, index, dataSum):
if dataSum == S:
count[0] += 1
for start in range(index + 1, len(dataArray)):
DFS(S, dataArray, count, start, dataSum + dataArray[start])
def solution():
N, S = sys.stdin.readline().split()
dataArray = list(map(int, sys.stdin.readline().split()))
count = [0]
for start in range (len(dataArray)):
DFS(int(S), dataArray, count, start, dataArray[start])
print(count[0])
solution()
https://www.acmicpc.net/problem/1182
Leave a comment