본문 바로가기
Computer Science

동한이의 정수 나열

by OKOK 2019. 2. 19.

1. 이렇게 해시 사용가능

2. 오케이

3. 1000 개 안에 만들 수 있는지 확인 함

4. 정당성 확보함

5. 오케이 


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
#include <stdio.h>
int testCase;
 
int main() {
 
    freopen("input.txt""r", stdin);
    scanf("%d"&testCase);
    int list[1001];
    int hash[1001];
 
    for (int tc = 1; tc <= testCase; tc++) {
        int N;
 
        scanf("%d"&N);
 
        for (int i = 0; i <= 1000; i++) {
            hash[i] = -1;
        }
 
        for (int i = 0; i<N; i++) {
            scanf("%d"&list[i]);
        }
 
        //1자리
        for (int i = 0; i<N; i++) {
            hash[list[i]] = 1;
        }
        //2자리
        for (int i = 0; i<- 1; i++) {
            hash[list[i] * 10 + list[i + 1]] = 1;
        }
 
        //3자리
        for (int i = 0; i<- 2; i++) {
            hash[list[i] * 100 + list[i + 1* 10 + list[i + 2]] = 1;
        }
 
        int min;
        for (int i = 0; i<1001; i++) {
 
            if (hash[i] == -1) {
                min = i;
                break;
            }
        }
        printf("%d\n", min);
    }
    return 0;
}
 
cs

 


'Computer Science' 카테고리의 다른 글

가능한 시험 점수  (0) 2019.02.19
문제 풀이  (0) 2019.02.19
승률 비교하기  (0) 2019.02.19
영준이의 카드 카운팅  (0) 2019.02.19
영빈이의 대량할인  (0) 2019.02.19

댓글