From 1b896a22d8a412b1d282a220c0aee520b57972b3 Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Tue, 4 Feb 2025 21:27:56 +0900 Subject: [PATCH] =?UTF-8?q?[20250204]=20BOJ=20/=20=EC=8B=A4=EB=B2=842=20/?= =?UTF-8?q?=20=EB=B3=84=EC=B0=8D=EA=B8=B0=20-=2022=20/=20=EC=84=A4?= =?UTF-8?q?=EC=A7=84=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\353\263\204\354\260\215\352\270\260 - 22" | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 "Seol-JY/202502/04 BOJ S2 \353\263\204\354\260\215\352\270\260 - 22" diff --git "a/Seol-JY/202502/04 BOJ S2 \353\263\204\354\260\215\352\270\260 - 22" "b/Seol-JY/202502/04 BOJ S2 \353\263\204\354\260\215\352\270\260 - 22" new file mode 100644 index 00000000..ee3cf369 --- /dev/null +++ "b/Seol-JY/202502/04 BOJ S2 \353\263\204\354\260\215\352\270\260 - 22" @@ -0,0 +1,63 @@ +```java +import java.io.*; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + + if (N == 1) { + System.out.println("*"); + return; + } + + char[][] map = new char[3 + 4 * (N-1)][1 + 4 * (N-1)]; + for (int i = 0; i < 3+4*(N-1); i++) { + for (int j = 0; j < 1+4*(N-1); j++) { + map[i][j] = ' '; + } + } + + int r = N * 2; + int c = N * 2 - 2; + int directionR = 1; + int directionC = -1; + int weight = 1; + for (int i = 0; i < 1+4*(N-1); i++) { + if (i % 2 == 0) { + directionR *= -1; + weight += 2; + for (int j = 0; j < weight; j++) { + r = j!=0 ? r + directionR : r; + map[r][c] = '*'; + } + } else { + directionC *= -1; + for (int j = 0; j < weight; j++) { + c = j!=0 ? c + directionC : c; + map[r][c] = '*'; + } + } + } + + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + for (int i = 0; i < 3+4*(N-1); i++) { + for (int j = 0; j < 1+4*(N-1); j++) { + if (i == 0) { + bw.write("*"); + continue; + } + if (i == 1 && j >= 1) continue; + if (j == 4*N - 4) { + bw.write(map[i][j]); + } else { + bw.write(map[i][j]); + } + } + bw.write("\n"); + } + bw.flush(); + bw.close(); + } +} +```