728x90
programmers carpet
-
[프로그래머스] 완전 탐색 - 카펫 c++Coding Test/programmers 2022. 5. 17. 17:38
입출력 예) Brown Yellow return 10 2 [4, 3] 8 1 [3, 3] 24 24 [8, 6] Brown, Yellow를 매개변수로 입력 받았을 때 return값에 대한 규칙이 있다. 1) Brown + Yellow = x * y 식으로 표현할 수 있다. 2) Brown + Yellow 의 공약수를 중에 3) (x-2) * (y-2) == Yellow 를 만족하는 값이 return 값이다. #include #include #include //stack #include //sqrt : 제곱근을 구하는 함수 using namespace std; vector solution(int brown, int yellow) { //brown + yellow = x * y int sum = brown ..