-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSRound70A.java
More file actions
53 lines (49 loc) · 1.32 KB
/
Copy pathCSRound70A.java
File metadata and controls
53 lines (49 loc) · 1.32 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
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author rn-sshawish
*/
public class CSRound70A {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int start = input.nextInt();
int end = input.nextInt();
int maxCount = Integer.MIN_VALUE;
int value = 0;
for (int i = start; i <= end; i++) {
int copyValue = i;
int holes = 0;
while (copyValue > 9) {
int target = copyValue % 10;
holes += getNumberOfHoles(target);
copyValue = copyValue / 10;
}
if (copyValue > -1) {
holes += getNumberOfHoles(copyValue);
}
if (holes > maxCount) {
maxCount = holes;
value = i;
}
}
System.out.println(value);
}
public static int getNumberOfHoles(int n) {
switch (n) {
case 4:
case 6:
case 9:
case 0:
return 1;
case 8:
return 2;
default:
return 0;
}
}
}