개미군단

    [JS] 개미 군단

    간단한 그리디 알고리즘이라 생각할 수 있는 문제이다. 장군개미 , 병정개미, 일개미 순으로 최대한 많이 넣을 수 있을만큼 넣게 하면 된다. function solution(hp) { const g_ant = parseInt(hp/5) const s_ant = parseInt( ( hp % 5 ) / 3) const o_ant = ( hp % 5 ) % 3 return g_ant + s_ant + o_ant }