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

 

이번에 볼 문제는 백준 12517번 문제인 Centauri Prime (Small1)이다.
문제는 아래 링크를 확인하자.

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

 

12517번: Centauri Prime (Small1)

Back in the old days before the creation of the mighty Centauri Republic, the planet Centauri Prime was split into several independent kingdoms. The kingdom of Mollaristan was ruled by king Loatold, while the kingdom of Auritania was under the rule of quee

www.acmicpc.net

12518번 문제(링크)에서 입력의 크기가 작아진 문제이다.

 

위의 문제와의 입력의 크기 차이로 더 쉬운 풀이가 생기거나 하지는 않으므로, 해당 문제의 풀이를 참고해 문제를 해결하자.

 

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

#include <iostream>
#include <string>
using namespace std;

int T;
string s;
bool isvowel[128];

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

	isvowel['a'] = isvowel['e'] = isvowel['i'] = isvowel['o'] = isvowel['u'] = 1;

	cin >> T;
	for (int t = 1; t <= T; t++) {
		cin >> s;
		cout << "Case #" << t << ": " << s << " is ruled by ";
		if (tolower(s.back()) == 'y') {
			cout << "nobody.\n";
		}
		else if (isvowel[tolower(s.back())]) cout << "a queen.\n";
		else cout << "a king.\n";
	}
}
728x90

+ Recent posts