본문 바로가기
알고리즘/그리디 알고리즘

1783 병든 나이트

by tryotto 2019. 6. 27.
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
#include <stdio.h>
 
int main() {
    int y, x;
    scanf("%d %d"&y, &x);
 
    if (y == 1) {
        printf("1");
    }
    else if (y == 2) {
        if (x < 9) {
            printf("%d", (x + 1/ 2);
        }
        else {
            printf("4");
        }
    }
    else {
        if (x <= 4) {
            printf("%d", x);
        }
        else if (5 <= x && x < 7) {
            printf("4");
        }
        else {
            printf("%d", x - 2);            
        }
    }
    return 0;
}
cs


'알고리즘 > 그리디 알고리즘' 카테고리의 다른 글

1507 궁금한 민호  (0) 2019.06.27
1343 폴리노미오  (0) 2019.06.27
1138 한 줄로 서기  (0) 2019.06.27
2437 저울  (0) 2019.06.27
1080 행렬  (0) 2019.06.23