프로그래밍
C# 카펫 - 완전탐색
노마드선샤인
2023. 1. 29. 12:44
728x90
using System;
using System.Numerics;
public class Solution
{
public int[] solution(int brown, int yellow)
{
int[] answer = new int[] { 3, 3 };
int y;
int width = brown + yellow;
for (int x = 1; x <= width; x++)
{
y = width / x;
if(x < y)
continue;
if ((width - ((x * 2) + (y * 2) - 4)) == yellow)
{
answer[0] = x;
answer[1] = y;
return answer;
}
}
return answer;
}
}
/// 다른 분의 코드가 너무 잘 되어 있어서 ㅠ
728x90