Created
October 3, 2019 09:55
-
-
Save surinoel/1a7413102c9267eb88e24ca09015d93f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <vector> | |
using namespace std; | |
vector<int> solution(int brown, int red) { | |
vector<int> answer; | |
int b, r; | |
b = brown, r = red; | |
for (int i = 1; i*i <= r; i++) { | |
if (r%i == 0) { | |
int h, w; | |
h = i, w = r / i; | |
if (b == 4 + h * 2 + w * 2) { | |
answer.push_back(w + 2); | |
answer.push_back(h + 2); | |
return answer; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment