Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created October 3, 2019 09:55
Show Gist options
  • Save surinoel/1a7413102c9267eb88e24ca09015d93f to your computer and use it in GitHub Desktop.
Save surinoel/1a7413102c9267eb88e24ca09015d93f to your computer and use it in GitHub Desktop.
#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