어렵진 않다.

곱으로 풀려다가 합으로 구현한 이유는 합이 곱보다 연산 속도가 빠르기 때문이다.

#include <string>
#include <vector>

using namespace std;

vector<long long> solution(int x, int n) {
    vector<long long> answer;

    for (int i = 0, temp = x; i < n; i++, temp += x)
        answer.push_back(temp);

    return answer;
}

+ Recent posts