※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※
이번에 볼 문제는 백준 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
'BOJ' 카테고리의 다른 글
[BOJ 24039 // C++] 2021은 무엇이 특별할까? (0) | 2023.02.21 |
---|---|
[BOJ 12871 // C++] 무한 문자열 (0) | 2023.02.21 |
[BOJ 9694 // C++] 무엇을 아느냐가 아니라 누구를 아느냐가 문제다 (0) | 2023.02.21 |
[BOJ 9324 // C++] 진짜 메시지 (0) | 2023.02.21 |
[BOJ 1417 // C++] 국회의원 선거 (0) | 2023.02.21 |