👉 문제 바로가기
약간의 수학적 사고력각 단계에서 오각형의 점이 증가하는 규칙을 찾으면 된다. 내가 찾은 규칙은 아래와 같다.
i 단계 점의 개수 = i-1단계 점의 개수 + (i*2) + (i+1)
각 단계의 점의 개수를 구한 후 45678로 나눈 나머지를 계속 저장해 나간다.
마지막으로 입력받은 N단계의 점의 개수를 출력한다.
#include <iostream>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
int n, dot_cnt = 1;
std::cin >> n;
for (int i = 1 ; i <= n; ++i) {
dot_cnt += ((i*2)+(i+1));
dot_cnt %= 45678;
}
std::cout << dot_cnt << std::endl;
return 0;
}