-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_1065.java
More file actions
56 lines (47 loc) Β· 1.09 KB
/
_1065.java
File metadata and controls
56 lines (47 loc) Β· 1.09 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package backjoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// https://www.acmicpc.net/problem/1065
// νμ
// νμ리μμ νμ κ°μ: 9 (1~9)
// λμ리μμ νμ κ°μ: 99 (1~99)
// μλ₯Ό λ€μ΄, 110μ νμ κ°μ: 99 (1~99)
// μλ₯Ό λ€μ΄, 111μ νμ κ°μ: 100 (1~99 + 111 = μ΄ 100κ°)
public class _1065 {
public static void main(String[] args) throws IOException {
//memory 11496 run 84
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int cnt;
if(n < 100 ){
System.out.println(n);
}else{
cnt = 99;
for(int i=100; i<=n; i++){
int hundreds = i / 100 % 10;
int tens = i / 10 % 10;
int units = i % 10;
// λ±μ°¨μμ΄μΈμ§ νμΈνκΈ°
if ((hundreds - tens) == (tens - units)) {
cnt++;
}
}
// μ£μ§μΌμ΄μ€
if (n == 1000){
cnt--;
}
System.out.println(cnt);
}
}
}
/*
input
110
1
210
output
99
1
105
*/