-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_2839.java
More file actions
41 lines (35 loc) ยท 779 Bytes
/
_2839.java
File metadata and controls
41 lines (35 loc) ยท 779 Bytes
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
32
33
34
35
36
37
38
39
40
41
package backjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// https://www.acmicpc.net/problem/2839
// ์คํ
public class _2839 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// memory 11492 runtime 76
int min = 0;
int N = Integer.parseInt(br.readLine());
while(true){
// 5์ ๋ฐฐ์์ธ ๊ฒฝ์ฐ ์ถ๋ ฅ
if(N % 5 == 0){
min += N/5;
break;
}
// 5์ ๋ฐฐ์๊ฐ ์๋ ๊ฒฝ์ฐ N์์ 3์ ๋นผ์ฃผ๊ณ ํ์๋ 1 ๋ํด์ค๋ค.
N -= 3;
min++;
if(N < 0){
min = -1;
break;
}
}
System.out.println(min);
}
}
/*
input
18
output
4
*/