🔗문제링크
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
👩💻참고 블로그
https://serendipity24.tistory.com/112
[SW Expert Academy][D3][Python] 2817. 부분 수열의 합
https://swexpertacademy.com/main/code/problem/problemDetail.do SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 동아리에서 푼 문제! 거의 하루 동안 풀었
serendipity24.tistory.com
모든 경우의 수를 다 탐색해보는 완전 탐색 문제
def solve(idx, sum):
global cnt
if idx >=n:
return
temp=sum+a[idx]
if temp==k:
cnt+=1
solve(idx+1, sum)
solve(idx+1, temp)
t=int(input())
for tc in range(1,t+1):
n,k = map(int,input().split())
a = list(map(int,input().split()))
cnt=0
solve(0,0)
print(f'#{tc} {cnt}')
'코딩테스트' 카테고리의 다른 글
swea. D3 - 1216. [S/W 문제해결 기본] 3일차 - 회문2 Python (0) | 2023.11.10 |
---|---|
swea. D3- 1220. [S/W 문제해결 기본] 5일차 - Magneti python (0) | 2023.11.09 |
DP(Dynamic Programming) 동적 프로그래밍 이란? (0) | 2023.05.20 |
분할정복(Divide and Conquer)이 무엇인가? (0) | 2023.05.12 |