웅재의 코딩세상
[프로그래머스] 등차수열의 특정한 항만 더하기 본문
- 풀이
#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;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] 뒤에서 5등 위로 (0) | 2024.01.24 |
---|---|
[프로그래머스] 접두사인지 확인하기 (0) | 2024.01.24 |
[프로그래머스] 코드 처리하기 (0) | 2024.01.24 |
[프로그래머스] 주사위 게임 2 (1) | 2024.01.24 |
[프로그래머스] 이어 붙인 수 (0) | 2024.01.24 |