코딩테스트/프로그래머스 - LV 0
[프로그래머스] 등차수열의 특정한 항만 더하기
웅드
2024. 1. 24. 23:43
- 풀이
#include <string>
#include <vector>
using namespace std;
int solution(int a, int d, vector<bool> included) {
int answer = 0;
for(int i=0; i< included.size(); i++){
if(included[i] == true){
answer += a;
}
a += d;
}
return answer;
}
반응형