알고리즘/백준(131)
-
[백준 1182번] 부분집합의 합
소스코드123456789101112131415161718192021222324#include using namespace std; int n, num[21], des, cnt=0; void cal(int idx, int sum) { sum += num[idx]; if (idx >= n) return; if (sum == des) cnt++; cal(idx + 1, sum-num[idx]); cal(idx + 1, sum);} int main() { cin >> n >> des; for (int i = 0; i > num[i]; } cal(0, 0); cout
2017.07.27 -
[백준 1799번] 비숍
소스코드123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172#include using namespace std; int n, board[11][11], Max = 0, visit[21] = { 0, }, visit_1[21] = { 0, }; void white(int a, int b, int cnt) { if (cnt > Max) Max = cnt; if (b >= n) { a++; if (a % 2 == 0) b = 0; else b = 1; } if (a >= n) return; if (visit[a + b] =..
2017.07.26 -
[백준 2493번] 탑
소스코드12345678910111213141516171819202122232425262728293031323334353637#include using namespace std; int main() { int n,building[500001],result[500001]; int Max=0, Max_idx=0, Mid=0, Mid_idx=0; cin >> n; for (int i = 1; i > building[i]; } for (int i = 1; i Max) { result[i] = 0; Max = building[i]; Max_idx = i; } else if (building[i]
2017.07.26 -
[백준 2879번] 코딩은 예쁘게
소스코드1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253#include using namespace std; int n, num[2][1002],cnt=0,idx=0,r=0; int main() { cin >> n; for (int i = 0; i num[i][j]; if (i == 1) num[0][j] = num[1][j] - num[0][j]; } } bool chk = num[0][0]
2017.07.25 -
[백준 9465번] 스티커
소스코드1234567891011121314151617181920212223242526272829303132333435363738#include using namespace std; int Max(int a, int b) { return a > b ? a : b;} int main() { int tc; cin >> tc; while (tc > 0) { int n,num[2][100001],dp[2][100001]; cin >> n; for (int i = 0; i > num[0][i]; for (int i = 0; i > num[1][i]; dp[0][0] = num[0][0]; dp[1][0] = num[1][0]; dp[0][1] = num[1][0] + num[0][1]; dp[1][1] = num[..
2017.07.24 -
[백준 1963번] 소수 경로
소스코드123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475#include using namespace std; int a, b, visit[10001] = { 0, };int que[10001], head = 0, tail = 0;int n_que[10001], n_head = 0, n_tail = 0; void push(int a) { que[tail++] = a;}int pop() { return que[head++];}void n_push(int a) { n_que[n_tail++] = a;}int ..
2017.07.24