백준 2839번(Java)

박은지·2025년 2월 9일
0

백준

목록 보기
26/89
post-thumbnail

import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		
		if(N == 4 || N == 7) {
			System.out.println(-1);
		}
		else if(N % 5 == 0) {
			System.out.println(N/5);
		}
		else if(N % 5 == 1 || N % 5 == 3) {
			System.out.println((N/5)+1);
		}
		else if(N % 5 == 2 || N % 5 == 4) {
			System.out.println((N/5)+2);
		}
	}
}
profile
백엔드 개발자가 되고싶은 eunzi😊

0개의 댓글