KDHzoot's Github

Code for study, project, etc

자세히보기

알고리즘/PS

[백준 2447] 별찍기 - 10

kdhzoot 2018. 5. 18. 20:29

전체 사각형을 *로 초기화 한뒤

연산을 통해 중간중간에 구멍을 송송 뚫으면 된다.

작은 것을 뚫고 점점 더 큰 범위를 뚫으면 된다. 


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
#include <stdio.h>
#include <string.h>
 
char arr[2200][2200= {};
 
 
 
int main(void){
    int n;
    memset(arr, '*'sizeof(arr));
    scanf("%d"&n);
 
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){    //한칸에 대한 결정
            int k = 3;
            while (k <= n){
                int x = i % k;
                int y = j % k;
                int tmp = k / 3;
                if (x >= tmp&&< 2 * tmp&&>= tmp&&< 2 * tmp){
                    arr[i][j] = ' ';
                }
                k *= 3;
            }
        }
    }
 
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            printf("%c", arr[i][j]);
        }
        printf("\n");
    } 
    
}
cs


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

[백준 1202] 보석도둑  (0) 2018.05.18
[백준 13302] 리조트  (0) 2018.05.18
[백준 7576] 토마토  (0) 2018.05.18
[백준 2448] 별찍기 - 11  (0) 2018.05.18
2의 n승 출력하기 (large)  (0) 2018.05.18