본문 바로가기
Algorithm & SQL/BAEKJOON

백준 JAVA 2839 설탕 배달

by YoonJong 2022. 7. 13.
728x90

 

package BAEKJOON;

import java.util.Scanner;

public class NO2839_2 {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int count = 0; // 봉지개수

        while (N != 0) {
            if (N % 5 == 0) {
                count += N / 5;
                break;
            } else {
                N = N - 3;
                count++;
            }
            if(N < 0 ) {
                count = -1;
                break;
            }
        }
        System.out.println(count);
    }
}
728x90

'Algorithm & SQL > BAEKJOON' 카테고리의 다른 글

백준 JAVA 4948 베르트랑 공준  (0) 2022.07.14
백준 JAVA 2581 소수  (0) 2022.07.13
백준 JAVA 10757 큰 수 A+B  (0) 2022.07.12
백준 JAVA 2775 부녀회장이 될테야  (0) 2022.07.12
백준 JAVA 10250 ACM 호텔  (0) 2022.07.12

댓글