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
 
public class Main {
    
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        
        //reads all the input strings and converts into int 
        int r = 0;
        String str = null;
        int[] numArr = new int[10];
        while((str = br.readLine()) != null) {
            numArr[r] = Integer.parseInt(str);
            r++;
            if(r == 10break;
        }
        
        //if checkarr index is remainder of 42 equal to 0, add 1 itself and increase r 
        r = 0;
        int[] checkArr = new int[1000];
        for(int i = 0; i < numArr.length; i++) {
            if(checkArr[numArr[i] % 42== 0) {
                checkArr[numArr[i] % 42]++;
                r++;
            }
        }
        
        bw.write(String.valueOf(r));
        bw.flush();
        
        
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
 

'알고리즘' 카테고리의 다른 글

백준 5단계(8958)  (0) 2019.11.28
백준 5단계(1546)  (0) 2019.11.28
백준 5단계(2577)  (0) 2019.11.28
백준 5단계(2920)  (0) 2019.11.28
코테 11/25/19  (0) 2019.11.25

+ Recent posts