알고리즘/BOJ

백준 2959번 거북이

꾸준함. 2021. 5. 7. 02:17

문제 링크입니다: www.acmicpc.net/problem/2959

 

2959번: 거북이

첫째 줄에 거북이가 생각한 네 양의 정수 A, B, C, D가 주어진다. (0 < A, B, C, D < 100)

www.acmicpc.net

간단한 수학 문제였습니다.

A, B, C, D를 정렬했을 때 제일 작은 수와 두 번째로 큰 수가 최대 크기 직사각형의 가로와 세로가 됩니다.

 

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX = 4;
int main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(0);
vector<int> footsteps(MAX);
for (int i = 0; i < MAX; i++)
{
cin >> footsteps[i];
}
sort(footsteps.begin(), footsteps.end());
int result = footsteps[0] * footsteps[2];
cout << result << "\n";
return 0;
}
view raw .cpp hosted with ❤ by GitHub

 

개발환경:Visual Studio 2017

 

지적, 조언, 질문 환영입니다! 댓글 남겨주세요~

반응형