문제 링크입니다: www.acmicpc.net/problem/8723
8723번: Patyki
Pierwszy wiersz wejścia zawiera trzy liczby całkowite a, b, c (1 ≤ a, b, c ≤ 1000), oznaczające odpowiednio długości pierwszego, drugiego i trzeciego patyka.
www.acmicpc.net
피타고라스의 법칙만 알고 있다면 쉽게 풀 수 있는 문제였습니다.
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 <algorithm> | |
using namespace std; | |
const int MAX = 3; | |
void printResult(int a, int b, int c) | |
{ | |
// 정삼각형 | |
if (a == b && b == c && c == a) | |
{ | |
cout << 2 << "\n"; | |
return; | |
} | |
// 직각 삼각형 | |
if (c*c == a * a + b * b) | |
{ | |
cout << 1 << "\n"; | |
return; | |
} | |
cout << 0 << "\n"; | |
} | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int triangleLengths[MAX]; | |
for (int i = 0; i < MAX; i++) | |
{ | |
cin >> triangleLengths[i]; | |
} | |
sort(triangleLengths, triangleLengths + MAX); | |
printResult(triangleLengths[0], triangleLengths[1], triangleLengths[2]); | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 9524번 Beautiful Yekaterinburg (0) | 2021.03.14 |
---|---|
백준 9498번 시험 성적 (0) | 2021.03.14 |
백준 8718번 Bałwanek (0) | 2021.03.14 |
백준 8710번 Koszykarz (0) | 2021.03.14 |
백준 6778번 Which Alien? (0) | 2021.03.13 |