https://school.programmers.co.kr/learn/courses/30/lessons/42840
숫자가 반복되는 주기를 이용해서 (index % 반복 주기)로 팍팍 대입해주면되는데 괜히 규칙 찾으려고 생각하다 시간 씀
중괄호 해주기
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> answers) {
vector<int> answer;
vector<int> a, b, c;
int cnt_a=0, cnt_b=0, cnt_c=0, Max=0;
for(int i=1; i<=answers.size(); i++) {
if(i%5 != 0)
a.push_back(i%5);
else
a.push_back(5);
if(i%8 == 2)
b.push_back(1);
else if(i%8 == 4)
b.push_back(3);
else if(i%8 == 6)
b.push_back(4);
else if(i%8 == 0)
b.push_back(5);
else
b.push_back(2);
if((i%10 == 1) || (i%10 == 2))
c.push_back(3);
else if((i%10 == 3) || (i%10 == 4))
c.push_back(1);
else if((i%10 == 5) || (i%10 == 6))
c.push_back(2);
else if((i%10 == 7) || (i%10 == 8))
c.push_back(4);
else
c.push_back(5);
}
for(int i=0; i<answers.size(); i++) {
if(answers[i] == a[i]) cnt_a++;
if(answers[i] == b[i]) cnt_b++;
if(answers[i] == c[i]) cnt_c++;
}
Max = max({cnt_a, cnt_b, cnt_c});
cout << cnt_a << cnt_b << cnt_c << Max;
if(Max == cnt_a) answer.push_back(1);
if(Max == cnt_b) answer.push_back(2);
if(Max == cnt_c) answer.push_back(3);
return answer;
}