완전탐색으로 풀려다가 규칙이 있는거 같아 확인해 보니 풀렸다.

경우의 수로 미리 설정해두고 풀었다.

#include <string>
#include <vector>

using namespace std;

int solution(string word) {
    int answer = word.length();
    int n[] = { 781, 156, 31, 6, 1 };
    string alpha = "AEIOU";
    
    for (int i = 0; i < word.length(); i++)
        answer += n[i] * alpha.find(word[i]);

    return answer;
}

+ Recent posts