전체 글 142

BAEKJOON 1004 - 어린왕자

문제: https://www.acmicpc.net/problem/1004 start 와 goal 지점을 둘러싸고 있는 행성의 개수를 구하는 방법으로 풀었습니다. 단, start 와 goal 둘 다 둘러싸고 있는 행성은 제하였습니다. my solvingc++12345678910111213141516171819202122232425262728293031323334353637383940414243444546#include #include #include using namespace std; struct Pos{ int x, y, r;}; bool whetherAEncloseB(Pos a, Pos b){ return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)..

BAEKJOON 1003 - 파보나치 함수

문제: https://www.acmicpc.net/problem/1003 파보나치를 구할 수 있는 재귀함수에서 0 과 1인 경우가 불리는 횟수는 나열을 해보면0의 경우 주어진 n - 1 의 파보나치 수1의 경우 주어진 n 의 파보나치 수와 같다는 것을 알 수 있습니다.그리고 파보나치 수의 경우 n이 커지면 시간복잡도가 매우 커지기 때문에 memoization 을 사용해 시간 복잡도를 줄여 풀었습니다. my solvingc++1234567891011121314151617181920212223242526272829303132333435363738394041#include #include #include #include using namespace std; map cache;int fibonacci_dp(in..

BAEKJOON 1002 - 터렛

문제: https://www.acmicpc.net/problem/1002 두 원 사이의 접점을 구하는 문제입니다. 해외 judge 사이트에 비해 어려웠던 점은 실패 시 어느 부분이 틀렸는지 정보를 제공해주지 않는다는 점입니다. 마지막으로 터렛안에 군인이 있을지는 생각 못했었네요 ㅋㅋ; my solvingc++12345678910111213141516171819202122232425262728293031323334353637383940414243444546#include #include #include #include using namespace std; struct Pos{ int x, y, r;}; int getNumIntersection(Pos a, Pos b){ double distance_cent..

USACO 2.1 - Sorting a Three-Valued Sequence

Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at most three different key values. This happens for instance when we sort medalists of a competition according to medal value, that is, gold medalists come first, followed by silver, and bronze medalists come last.In this task the possible key values a..