๐Ÿ’  Cpp/[BOJ] ๋‹จ๊ณ„๋ณ„๋กœ ํ’€์–ด๋ณด๊ธฐ

[BOJ][C++] ๋ฐฑ์ค€ 5073๋ฒˆ: ์‚ผ๊ฐํ˜•๊ณผ ์„ธ ๋ณ€ (Bronze III)

์„ ๋‹ฌ 2024. 12. 28. 19:26
๋ฐ˜์‘ํ˜•

๋ฌธ์ œ

์‚ผ๊ฐํ˜•์˜ ์„ธ ๋ณ€์˜ ๊ธธ์ด๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ ๋ณ€์˜ ๊ธธ์ด์— ๋”ฐ๋ผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ •์˜ํ•œ๋‹ค.
๋‹จ ์ฃผ์–ด์ง„ ์„ธ ๋ณ€์˜ ๊ธธ์ด๊ฐ€ ์‚ผ๊ฐํ˜•์˜ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜์ง€ ๋ชปํ•˜๋Š” ๊ฒฝ์šฐ์—๋Š” "Invalid" ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด 6, 3, 2๊ฐ€ ์ด ๊ฒฝ์šฐ์— ํ•ด๋‹นํ•œ๋‹ค. ๊ฐ€์žฅ ๊ธด ๋ณ€์˜ ๊ธธ์ด๋ณด๋‹ค ๋‚˜๋จธ์ง€ ๋‘ ๋ณ€์˜ ๊ธธ์ด์˜ ํ•ฉ์ด ๊ธธ์ง€ ์•Š์œผ๋ฉด ์‚ผ๊ฐํ˜•์˜ ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜์ง€ ๋ชปํ•œ๋‹ค.
์„ธ ๋ณ€์˜ ๊ธธ์ด๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ ์œ„ ์ •์˜์— ๋”ฐ๋ฅธ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•˜์‹œ์˜ค.

์ž…๋ ฅ

๊ฐ ์ค„์—๋Š” 1,000์„ ๋„˜์ง€ ์•Š๋Š” ์–‘์˜ ์ •์ˆ˜ 3๊ฐœ๊ฐ€ ์ž…๋ ฅ๋œ๋‹ค. ๋งˆ์ง€๋ง‰ ์ค„์€ 0 0 0์ด๋ฉฐ ์ด ์ค„์€ ๊ณ„์‚ฐํ•˜์ง€ ์•Š๋Š”๋‹ค.

์ถœ๋ ฅ

๊ฐ ์ž…๋ ฅ์— ๋งž๋Š” ๊ฒฐ๊ณผ (Equilateral, Isosceles, Scalene, Invalid) ๋ฅผ ์ถœ๋ ฅํ•˜์‹œ์˜ค.

 

ํ’€์ด

// ํ’€์ด : https://whkakrkr.tistory.com

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int INF = 100001;

int main() {
    ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	
	int a,b,c;
	string ans;
	while(cin >> a >> b >> c) {
	    if(a==0 && b==0 && c==0) {
	        break;
	    }
	    
	    if(!((a<b+c) && (b<a+c) && (c<a+b))) {
	        ans = "Invalid";
	    } else if(a==b && b==c) {
	        ans = "Equilateral";
	    } else if(a==b || b==c || a==c) {
	        ans = "Isosceles";
	    } else {
	        ans = "Scalene";
	    }
	    
	    cout << ans << "\n";
	}

    return 0;
}

 

๋ฐ˜์‘ํ˜•