From 6864979e469142869d85bf768b6beb432449a100 Mon Sep 17 00:00:00 2001 From: D0won Date: Wed, 16 Oct 2024 15:47:09 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"Revert=20"Post:=20=EC=95=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=EC=A6=98=20=EC=8A=A4=ED=84=B0=EB=94=94=201=EC=A3=BC?= =?UTF-8?q?=EC=B0=A8=20=EC=96=B8=EC=96=B4=ED=8C=80""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit affc2892777cc241b188c0d35a97026b9d905cf5. --- blog/_posts/2024-10-15-algo-w1-1.md | 82 +++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 blog/_posts/2024-10-15-algo-w1-1.md diff --git a/blog/_posts/2024-10-15-algo-w1-1.md b/blog/_posts/2024-10-15-algo-w1-1.md new file mode 100644 index 0000000..187f561 --- /dev/null +++ b/blog/_posts/2024-10-15-algo-w1-1.md @@ -0,0 +1,82 @@ +--- +layout: post +thumbnail: https://github.com/sunbaklee/tech-blog/assets/105528907/61f561c9-a338-41e5-bcba-528b62a79766 +title: "알고리즘 스터디 1주차" +date: 2024-10-15 +tags: [Embedded] +author: 이준혁 +--- + +# 백준 3303번 킹, 퀸, 룩, 비숍, 나이트, 폰 + +## 개선 전 코드 +``` +a, b, c, d, e, f = map(int, input().split()) +aa = bb = cc = dd = ee = ff = 0 + +if a == 1: + aa = 0 +else: + aa = -(a - 1) + + +if b == 1: + bb = 0 +else: + bb = -(b - 1) + +if c == 2: + cc = 0 +else: + cc = -(c - 2) + +if d == 2: + dd = 0 +else: + dd = -(d - 2) + +if e == 2: + ee = 0 +else: + ee = -(e - 2) + +if f == 8: + ff = 0 +else: + ff = -(f - 8) + +print(aa, bb, cc, dd, ee, ff) +``` + + + + + + + + +## 개선 후 코드 +``` +a, b, c, d, e, f = map(int, input().split()) +a = -(a -1) +b = -(b -1) +c = -(c - 2) +d = -(d - 2) +e = -(e - 2) +f = -(f - 8) +print(a, b, c, d, e, f) +``` + + +# 백준 2446 별찍기 + +``` +n = int(input()) +for i in range(n): + for i in range(n): + print(' ' * i, end = '') + print('*' * (2 * (n - i) - 1)) + for i in range(n-1): + print(' ' , end = '') + print('*' * (2*i+1)) +``` \ No newline at end of file