목록재귀함수 (2)
레야몬
[C++] 2263번 트리의 순회 - 트리, 분할 정복, 재귀
#include #define MAX_VERTEX 100001 using namespace std; int Index[MAX_VERTEX]; int io[MAX_VERTEX], po[MAX_VERTEX]; int n; void f(int io_left, int io_right, int po_left, int po_right) { if(io_left > io_right) return; int rootIndex = Index[po[po_right]]; int ls = rootIndex - io_left; cout po[i]; f(1, n, 1, n); return 0; } ㅈㄹ 어렵다.. 나에겐 아직 골드2는 버거운건가 참고한 사이트는 아래에 있다. 오랫만에 주석을 안적었는데.ㅠㅠ https://salgur..
알고리즘/백준
2022. 9. 3. 16:51
[C언어] 9095번 1, 2, 3 더하기 - DP
#include int memo[11]; int f(int n) { switch(n) { case 3: return 4; case 2: return 2; case 1: return 1; } if(memo[n]) //이미 메모되어 있는 경우 메모되어 있는 값 반환 return memo[n]; return memo[n] = f(n-1)+f(n-2)+f(n-3); //1, 2, 3의 합으로 재귀 } int main() { int T, n; //테스트 케이스의 개수, 정수 n int i; scanf("%d", &T); for(i=0; i
알고리즘/백준
2022. 8. 29. 19:53