BOJ - [Array - 2448 λ³μ°κΈ° - 11] - GOLD IVπ₯
https://www.acmicpc.net/problem/2448 μ΄ λ¬Έμ λν β2447 - λ³μ°κΈ° - 10β μ λΉμ·ν λ¬Έμ λ‘ λ€μν λͺ¨μμΌλ‘ λ³μ μ°λ λ¬Έμ λ€. μ΄λ² λ¬Έμ λ 2447λ²κ³Ό λΉμ·νκ² νλν λν ννμ λ³μ μ°λλ° μ΄λ²μλ 2447λ² λ¬Έμ μμ νλν λνμ μμλ‘...
λ¬Έμ
https://www.acmicpc.net/problem/2448
νμ΄
μ΄ λ¬Έμ λν β2447 - λ³μ°κΈ° - 10β μ λΉμ·ν λ¬Έμ λ‘ λ€μν λͺ¨μμΌλ‘ λ³μ μ°λ λ¬Έμ λ€.
μ΄λ² λ¬Έμ λ 2447λ²κ³Ό λΉμ·νκ² νλν λν ννμ λ³μ μ°λλ° μ΄λ²μλ 2447λ² λ¬Έμ μμ νλν λνμ μμλ‘ λ³΄μ¬μ€¬λ μΌκ°ν μ¬μ§μ λμΌνκ² κ΅¬νν΄μΌλλ λ¬Έμ λ€. 2447λ² λ¬Έμ : https://hoshi2710.github.io/%EB%B0%B1%EC%A4%80/2447

μΆμ² : https://m.blog.naver.com/jamogenius/220886627296
κ·Έλ¬λ 2447λ² μμ νμλ λ°©μμ κ·Έλλ‘ μ¬μ©νλ μκ° μ΄κ³Όμ κ±Έλ €λ²λ Έλ€.
2447λ²μμλ λ¨Όμ μ μΌ λ©μΈμΈ ν° λνμ λ§λ€κ³ srcλ°°μ΄μ κ·Έκ²λ³΄λ€ μμ νλν λνμ λ§λ€κ³ κ²°κ³Όλ¬Όμ λΆμ΄κΈ°λ₯Ό λ°λ³΅νλλ° μ΄λ¬Έμ μμλ κ·Έ κ³Όμ μ κ·Έλλ‘ μ μ©νμλ κ³Όμ μ΄ λ 볡μ‘ν΄μ§κ³ λ λ§μ μκ°μ΄ μμλμ΄ μ΄λ²μλ λ°©λ²μ μ½κ° λ³ν μμΌλ³΄μλ€.
λ°λ‘ μ μΌ ν° λνμ κ·Έλ¦¬κ³ λ λ€μ κ·Έ μ΄ν μμ μΌκ°νμ λΆμ΄λ λμ μΌκ°ν λͺ¨μμ 곡백μμμ κ³μ λ§λλ κ²μ΄λ€.

λμΆ© μ΄λ° μΌκ°νμ μ μΌ λ©μΈμΌλ‘ λ¨Όμ λ§λ λ€μ

μ΄λ° λͺ¨μμΌλ‘ 곡백μ λ£μ΄ μ μΌκ°ν λͺ¨μμΌλ‘ ꡬλ©μ λ«κ³ μ΄λ₯Ό λ°λ³΅νλλ‘ νλ κ²μ΄λ€.
μμ€
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
int main()
{
int height = 0, width = 0, looped = 1;
bool** res; //[μΈλ‘][κ°λ‘] (False = '*', True = ' ')
scanf("%d", &height);
width = height * 2 - 1;
int origin_width = width, origin_height = height;
res = (bool**)malloc(sizeof(bool*) * height);
for (int i = 0; i < height; i++)
{
res[i] = (bool*)malloc(sizeof(bool*) * width);
memset(res[i], true, sizeof(bool) * origin_width);
}
for (int j = origin_height - 1; j >= 0; j--) //λ³μ°κΈ°
memset(res[j] + (origin_height - j - 1), false, sizeof(bool) * (width - ((height - j - 1) * 2)));
for (int j = height / 2; j < height; j++) // κ°μ΄λ° λΉμΉΈ μ½μ
memset(res[j] + j + (height == 3 ? 1 : 0), true, sizeof(bool) * ((((width - 1) / 2) - ((j - (height / 2)) * 2)) - (height == 3 && j == 1 ? 1 : 0)));
while (height != 1)
{
width = (width - 1) / 2;
height /= 2;
for (int j = 1; j <= origin_height; j += origin_height / looped)
for (int find = origin_width/2 - j; find < origin_width/2+j; find++)
if (res[j - 1][find] == false)
for (int k = 0; k < height; k++) // κ°μ΄λ° λΉμΉΈ μ½μ
memset(res[j - 1 + k + height] + find - ((width - 1) / 2) + k, true, sizeof(bool) * (height != 1 ? (width - 2 * k) : 1));
looped *= 2;
}
for (int i = 0; i < origin_height; i++)
{
for (int j = 0; j < origin_width; j++)
putchar(!res[i][j] ? '*' : ' ');
putchar('\n');
}
free(res);
}
while λ¬Έ λΆλΆμμ μ°μμ μΌλ‘ μμΌκ°ν 곡백 ꡬλ©μ λ§λλ μμ μ΄ μ΄λ£¨μ΄ μ§λλ° μ μΌ ν° μΌκ°νμ λμ΄ κ°μ μ΄μ©ν΄ 1,2,4,8κ°μ μ€λ‘ μΈλ‘ ꡬμμ λλμ΄ μμΌκ°νμ΄ λ€μ΄κ° ꡬκ°μ forλ¬Έμ μ΄μ©ν΄ κ²μνκ³ μ΅μ’ μ μΌλ‘ 곡백 μμΌκ°νμ μ½μ νλ λ°©μμ΄λ€.