[프로그래머스 / C++] Lv 0. 개미군단

FinDer178·2024년 7월 11일
0

문제

문제풀이

풀이

#include <string>
#include <vector>

using namespace std;

int solution(int hp) {
    int answer = 0;
    
    answer+=(hp/5);
    hp%=5;
    
    answer+=(hp/3);
    hp%=3;
    
    answer+=hp;
    
    return answer;
}

처음에 if-else문으로 분기를 나눠서 하는걸로 생각했지만 굳이 그렇게 할 필요가 없었다.

profile
낙관적 개발자

0개의 댓글