본문 바로가기

Coding Test/프로그래머스

[프로그래머스/자바] 개미 군단

class Solution {
    public int solution(int hp) {
        int answer = 0;
        while(hp>=5){
            hp-=5;
            answer++;
        }
        while(hp>=3){
            hp-=3;
            answer++;
        }
        while(hp>0){
            hp--;
            answer++;
        }
        return answer;
    }
}

class Solution {
    public int solution(int hp) {
        return hp / 5 + (hp % 5 / 3) + (hp % 5 % 3);
    }
}