※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 24803번 문제인 Provinces and Gold이다.
문제는 아래 링크를 확인하자.

https://www.acmicpc.net/problem/24803 

 

24803번: Provinces and Gold

The input consists of a single test case on a single line, which contains three non-negative integers $G$, $S$, $C$ ($G + S + C \le 5$) indicating the number of Golds, Silvers, and Coppers Jake draws in his hand.

www.acmicpc.net

주어진 Gold, Silver, Copper 카드들을 이용해 Jake의 buying power를 계산하자.

 

위에서 계산한 buying power을 이용해 Jake가 살 수 있는 가장 좋은 victory card와 treasure card를 구해 문제를 해결하자.

 

아래는 제출한 소스코드이다.

#include <iostream>
using namespace std;

int G, S, C;
int bp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> G >> S >> C;
	bp = 3 * G + 2 * S + C;

	if (bp >= 8) cout << "Province or ";
	else if (bp >= 5) cout << "Duchy or ";
	else if (bp >= 2) cout << "Estate or ";

	if (bp >= 6) cout << "Gold";
	else if (bp >= 3) cout << "Silver";
	else cout << "Copper";
}
728x90

'BOJ' 카테고리의 다른 글

[BOJ 12572 // C++] Rope Intranet (Large)  (0) 2022.12.10
[BOJ 24080 // C++] 複雑な文字列 (Complex String)  (0) 2022.12.10
[BOJ 7782 // C++] Alien  (0) 2022.12.09
[BOJ 10168 // C++] 파발마  (0) 2022.12.09
[BOJ 26145 // C++] 출제비 재분배  (0) 2022.12.09

+ Recent posts