백준 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[문제 링크] https://www.acmicpc.net/problem/2580 [입출력 예] 입력 출력 0 3 5 4 6 9 2 7 8 7 8 2 1 0 5 6 0 9 0 6 0 2 7 8 1 3 5 3 2 1 0 4 6 8 9 7 8 0 4 9 1 3 5 0 6 5 9 6 8 2 0 4 1 3 9 1 7 6 5 2 0 8 0 6 0 3 7 0 1 9 5 2 2 5 8 3 9 4 7 6 0 1 3 5 4 6 9 2 7 8 7 8 2 1 3 5 6 4 9 4 6 9 2 7 8 1 3 5 3 2 1 5 4 6 8 9 7 8 7 4 9 1 3 5 2 6 5 9 6 8 2 7 4 1 3 9 1 7 6 5 2 3 8 4 6 4 3 7 8 1 9 5 2 2 5 8 3 9 4 7 6 1 [소스코드] //14:54 … -
백준 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[문제 링크] https://www.acmicpc.net/problem/3055 [입출력 예] 입력 출력 3 3 D.* …. .S. 3 [소스코드] import sys from collections import deque input = sys.stdin.readline dx=[1,0,-1,0] dy=[0,1,0,-1] r, c = list(map(int,input().split())) board1 = [] Dx, Dy , Sx,Sy=0,0,0,0 water=deque() for i in range(r): tmp=list(input().rstrip()) for j in range(c): if tmp[j]=='D': Dx =i Dy =j if tmp[j]=='S': Sx = i Sy = j if tmp[j…
댓글을 사용할 수 없습니다.