백준 1182 부분수열의 합 파이썬 풀이
[문제 링크]
https://www.acmicpc.net/problem/
[입출력 예]
입력 | 출력 |
---|---|
5 0 -7 -3 -2 5 8 |
1 |
[소스코드]
import sys input = sys.stdin.readline cnt=0 def func (i ,tot): if i==n: if tot==m: global cnt cnt+=1 return func(i+1,tot) func(i+1,tot+arr[i]) n,m=list(map(int,input().split())) arr=list(map(int,input().split())) func(0,0) if(m==0): cnt-=1 print(cnt)
'PS > BOJ' 카테고리의 다른 글
백준 1920 수 찾기 파이썬 (0) | 2022.02.18 |
---|---|
BOJ 2580 스도쿠 C++ (0) | 2022.02.16 |
백준 2178 미로탐색 C++ (0) | 2022.02.10 |
백준 3055번 탈출 파이썬 (0) | 2022.02.09 |
백준 15683 감시 C++ (0) | 2022.02.09 |
댓글
이 글 공유하기
다른 글
-
백준 1920 수 찾기 파이썬
백준 1920 수 찾기 파이썬
2022.02.18[문제 링크] https://www.acmicpc.net/problem/1920 [입출력 예] 입력 출력 5 4 1 5 2 3 5 1 3 7 9 5 1 1 0 0 1 [소스코드] import sys input=sys.stdin.readline from collections import deque input() a=list(map(int,input().split())) input() test=list(map(int,input().split())) for i,x in enumerate(test): test[i]=[x,i,0] a.sort() test.sort() a=deque(a) test=deque(test) ans=[] while(a and test): cur_a=a.popleft() cur_test=t… -
BOJ 2580 스도쿠 C++
BOJ 2580 스도쿠 C++
2022.02.16 -
백준 2178 미로탐색 C++
백준 2178 미로탐색 C++
2022.02.10[문제 링크] https://www.acmicpc.net/problem/2178 [입출력 예] 입력 출력 4 6 101111 101010 101011 111011 15 [소스코드] //20:35시작 #include using namespace std; #define X first #define Y second int board[100][100]; int v[100][100]; int n,m; int dx[4]= {1,0,-1,0}; int dy[4]= {0,1,0,-1}; void printBoard(){ for (int i=0; i -
백준 3055번 탈출 파이썬
백준 3055번 탈출 파이썬
2022.02.09
댓글을 사용할 수 없습니다.