Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

KSI일기장

프로그래머스 개미군단 (자바) 본문

JavaAlgorithm

프로그래머스 개미군단 (자바)

MyDiaryYo 2023. 11. 30. 15:58

 

 

 

 

 

public static void main(String[] args) {

        int hp = 999;
        int answer = 0;

        if((hp%5)==0){
            answer = hp/5;
        } else if ( (((hp%5)%3)==0) && ((hp%5) >= 3) ) {
            answer = (hp/5) + ((hp%5)/3);
        }else{
            answer=(hp/5) + ((hp%5)/3) + (((hp%5)%3)/1);
        }
        System.out.println(answer);
    }

 

 

 public static void main(String[] args) {

        int hp = 24;
        int answer = 0;

        answer = (hp/5) + ((hp%5) / 3) + ((hp%5) % 3);

        System.out.println(answer);
 }