diff --git a/과제2폴더/2-1.png b/과제2폴더/2-1.png new file mode 100644 index 0000000..d68a991 Binary files /dev/null and b/과제2폴더/2-1.png differ diff --git a/과제2폴더/2-1.txt b/과제2폴더/2-1.txt new file mode 100644 index 0000000..fc4bac0 --- /dev/null +++ b/과제2폴더/2-1.txt @@ -0,0 +1,14 @@ +#include +#include + +using namespace std; + +int solution(int n, int k) { + int answer = 0; + + // 총액 + answer = n * 12000; + answer += (k - (n / 10)) * 2000; + + return answer; +} \ No newline at end of file diff --git a/과제2폴더/2-2.png b/과제2폴더/2-2.png new file mode 100644 index 0000000..a6450f1 Binary files /dev/null and b/과제2폴더/2-2.png differ diff --git a/과제2폴더/2-2.txt b/과제2폴더/2-2.txt new file mode 100644 index 0000000..b3bab49 --- /dev/null +++ b/과제2폴더/2-2.txt @@ -0,0 +1,21 @@ +#include +#include + +using namespace std; + +int solution(vector> board, int k) { + int answer = 0; + + for (int i=0; i +#include +#include +#include +#include + +using namespace std; + +static bool comp(pair& a, pair& b){ + return a.second > b.second; +} + +int solution(int a, int b, int c, int d) { + int answer = 0; + map m; + m[a]++; + m[b]++; + m[c]++; + m[d]++; + + vector> v(m.begin(), m.end()); + sort(v.begin(), v.end(), comp); + + bool n3 = false; + bool n2 = false; + bool n1 = false; + bool n0 = false; + + for (auto it = v.begin(); it != v.end(); ++it) { + switch(it->second) + { + // 4개 같음 + case 4: + answer = 1111 * it->first; + break; + // 3개 같음 + case 3: + answer = 10 * it->first; + n3 = true; + break; + // 2개 같음 + case 2: + // 2개 이후 2개 + if (n2) + { + answer = (answer + it->first) * abs(answer - it->first); + break; + } + + answer = it->first; + n2 = true; + break; + // 1개 같음 + case 1: + // 3개 이후 1개 + if (n3) + { + answer = (answer + it->first) * (answer + it->first); + break; + } + + // 2개 이후 1개 + if (n2) + { + // 2개 이후 1개 이후 1개 + if (n1) + { + answer = answer * - it->first; + break; + } + + answer = - it->first; + n1 = true; + break; + } + + // 1개 이후 1개 + if (n1) + { + answer < it->first ? answer : it->first; + break; + } + + answer = it->first; + n1 = true; + break; + } + } + + return answer; +} \ No newline at end of file diff --git a/과제2폴더/2-4.png b/과제2폴더/2-4.png new file mode 100644 index 0000000..7e390d5 Binary files /dev/null and b/과제2폴더/2-4.png differ diff --git a/과제2폴더/2-4.txt b/과제2폴더/2-4.txt new file mode 100644 index 0000000..0edb85e --- /dev/null +++ b/과제2폴더/2-4.txt @@ -0,0 +1,35 @@ +#include +#include + +using namespace std; + +int solution(vector> dots) { + int answer = 0; + + // 뭐여 실수만 되네? + double dx = dots[0][0] - dots[1][0]; + double dy = dots[0][1] - dots[1][1]; + double dx2 = dots[2][0] - dots[3][0]; + double dy2 = dots[2][1] - dots[3][1]; + + if (dx/dy == dx2/dy2) + return 1; + + dx = dots[0][0] - dots[2][0]; + dy = dots[0][1] - dots[2][1]; + dx2 = dots[1][0] - dots[3][0]; + dy2 = dots[1][1] - dots[3][1]; + + if (dx/dy == dx2/dy2) + return 1; + + dx = dots[0][0] - dots[3][0]; + dy = dots[0][1] - dots[3][1]; + dx2 = dots[1][0] - dots[2][0]; + dy2 = dots[1][1] - dots[2][1]; + + if (dx/dy == dx2/dy2) + return 1; + + return answer; +} \ No newline at end of file