황소개발자
백준 1182 파이썬 python : 부분수열의 합 @@황소처럼 우직하게@@ 본문
반응형
import sys
input = sys.stdin.readline
n, s = map(int, input().split())
lst = list(map(int, input().split()))
ans = 0
def sub_sum(idx, total):
global ans, s
if idx == n:
if total == s:
ans += 1
return
sub_sum(idx + 1, total)
sub_sum(idx + 1, total + lst[idx])
sub_sum(0, 0)
ans -= 1 if s == 0 else 0
print(ans)
반응형
'백준 문제 풀이' 카테고리의 다른 글
백준 11723 파이썬 python : 집합 @@황소처럼 우직하게@@ (0) | 2020.02.28 |
---|---|
백준 14501 파이썬 python : 퇴사 @@황소처럼 우직하게@@ 재귀로 간단구현 (10) | 2020.02.28 |
백준 1759 파이썬 python : 암호 만들기 @@황소처럼 우직하게@@ 코로나 조심하세요 (0) | 2020.02.28 |
백준 6603 파이썬 python : 로또 - combination 직접구현 (0) | 2020.02.28 |
백준 10971 파이썬 python : 외판원 순회 2 @@황소처럼 우직하게@@ 아주나이쑤 (0) | 2020.02.28 |
Comments