알고리즘(139)
-
[백준 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 -
[백준 10819번] 차이를 최대로
소스코드1234567891011121314151617181920212223242526272829303132333435363738394041424344#include using namespace std; int n,num[9],Max=-98765; int cal_sum(int* num) { int sum = 0; for (int i = 2; i n; for (int i = 0; i > num[i]; } cal(num,0, n-1); cout
2017.07.23 -
[백준 1107번] 리모컨
소스코드123456789101112131415161718192021222324252627282930313233343536373839#include using namespace std; int n, m, broke[10] = {0,}; int main() { cin >> n >> m; for (int i = 0; i > a; broke[a] = 1; } int Min = (n - 100)
2017.07.23 -
[백준 5397번] 키로거
소스코드1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162#include using namespace std; char left_word[1000001], right_word[1000001];int left_sp = 0, right_sp = 0; void push_left(char a) { left_word[left_sp++] = a;}void push_right(char a) { right_word[right_sp++] = a;}char pop_left() { return left_word[--left_sp];}char pop_right() { re..
2017.07.23 -
[백준 2467번] 용액
소스코드12345678910111213141516171819202122232425262728293031323334353637383940414243444546#include using namespace std; int n;long long num[100001], Min = 9876543210, result_a, result_b; int main() { cin >> n; for (int i = 0; i > num[i]; } for (int i = 0; i = 1) { int mid = (l + r) / 2; if (num[mid] == (-1 * num[i])) { idx = mid; break; } else if (num[mid] (-1 * num[i])) { r = mid; } idx = mid; } i..
2017.07.23 -
[백준 10971번] 외판원 순회 2
소스코드1. DFS1234567891011121314151617181920212223242526272829303132333435363738394041#include using namespace std; int n, map[11][11], visit[11], Min=98765432,cnt=0; void dfs(int first, int a, int sum) { if (cnt == n && first == a) { if (Min > sum) { Min = sum; } return; } for (int i = 0; i > n; for (int i = 0; i map[i][j]; } visit[i] = 0; } for (int i = 0; i
2017.07.23