문제 링크입니다: www.acmicpc.net/problem/2959
2959번: 거북이
첫째 줄에 거북이가 생각한 네 양의 정수 A, B, C, D가 주어진다. (0 < A, B, C, D < 100)
www.acmicpc.net
간단한 수학 문제였습니다.
A, B, C, D를 정렬했을 때 제일 작은 수와 두 번째로 큰 수가 최대 크기 직사각형의 가로와 세로가 됩니다.
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 <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; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 2975번 Transactions (0) | 2021.05.09 |
---|---|
백준 2965번 캥거루 세마리 (0) | 2021.05.07 |
백준 2953번 나는 요리사다 (0) | 2021.05.05 |
백준 21611번 마법사 상어와 블리자드 (0) | 2021.05.03 |
백준 20058번 마법사 상어와 파이어스톰 (2) | 2021.05.03 |