Jam's story
[2839] 설탕배달 본문
import java.io.*;
public class Main {
static int count =0;
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
solve(n);
}
static void solve(int n) {
while(true) {
if(n%5 ==0) {
count += n/5;
System.out.println(count);
return;
}else {
n -= 3;
count++;
}
if(n<0) {
System.out.println(-1);
return;
}
}
}
}
'코딩테스트 > 백준' 카테고리의 다른 글
[백준] 2667번 단지번호 붙이기 - java (0) | 2022.08.05 |
---|---|
[백준] 7562번 나이트의 이동 - java (0) | 2022.08.04 |
[백준] 2178번 미로탐색 (0) | 2022.08.02 |
[1712번] 손익분기점 (0) | 2022.05.26 |
[백준 15596번] 정수 N개의 합 (0) | 2022.05.26 |
Comments