목록전체 글 (194)
레야몬
1012번 유기농 배추 - 그래프이론
#include #define MAX_STACK_SIZE 2500 int stack[MAX_STACK_SIZE][2]; int top=-1; int land[51][51]; int IsEmpty() { if(top
알고리즘/백준
2022. 8. 22. 19:20
1003번 피보나치 함수 - DP
#include typedef struct _values //두 개의 숫자를 반환하기 위한 구조체 { int one; int zero; } values; int note[41][2]; //메모리제이션 values fibonacci(int N) { values a, b, c; a.one=a.zero=b.one=b.zero=c.one=c.zero=0; //구조체 초기화 if(note[N][0] || note[N][1]) { //메모되있을 경우 사용 a.one+=note[N][1]; a.zero+=note[N][0]; return a; } c = fibonacci(N-2); //재귀함수 b = fibonacci(N-1); a.zero = b.zero + c.zero; a.one = b.one + c.one; ..
알고리즘/백준
2022. 8. 22. 15:41