Skip to content

Commit 303489f

Browse files
committed
Post: 알고리즘 스터디 1주차 언어팀
1 parent f24fcc5 commit 303489f

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

blog/_posts/2024-10-15-algo-w1-1.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
layout: post
3+
thumbnail: https://github.com/sunbaklee/tech-blog/assets/105528907/61f561c9-a338-41e5-bcba-528b62a79766
4+
title: "알고리즘 스터디 1주차"
5+
date: 2024-10-15
6+
tags: [Embedded]
7+
author: 이준혁
8+
---
9+
10+
# 백준 3303번 킹, 퀸, 룩, 비숍, 나이트, 폰
11+
12+
## 개선 전 코드
13+
```
14+
a, b, c, d, e, f = map(int, input().split())
15+
aa = bb = cc = dd = ee = ff = 0
16+
17+
if a == 1:
18+
aa = 0
19+
else:
20+
aa = -(a - 1)
21+
22+
23+
if b == 1:
24+
bb = 0
25+
else:
26+
bb = -(b - 1)
27+
28+
if c == 2:
29+
cc = 0
30+
else:
31+
cc = -(c - 2)
32+
33+
if d == 2:
34+
dd = 0
35+
else:
36+
dd = -(d - 2)
37+
38+
if e == 2:
39+
ee = 0
40+
else:
41+
ee = -(e - 2)
42+
43+
if f == 8:
44+
ff = 0
45+
else:
46+
ff = -(f - 8)
47+
48+
print(aa, bb, cc, dd, ee, ff)
49+
```
50+
51+
52+
53+
54+
55+
56+
57+
58+
## 개선 후 코드
59+
```
60+
a, b, c, d, e, f = map(int, input().split())
61+
a = -(a -1)
62+
b = -(b -1)
63+
c = -(c - 2)
64+
d = -(d - 2)
65+
e = -(e - 2)
66+
f = -(f - 8)
67+
print(a, b, c, d, e, f)
68+
```
69+
70+
71+
# 백준 2446 별찍기
72+
73+
```
74+
n = int(input())
75+
for i in range(n):
76+
for i in range(n):
77+
print(' ' * i, end = '')
78+
print('*' * (2 * (n - i) - 1))
79+
for i in range(n-1):
80+
print(' ' , end = '')
81+
print('*' * (2*i+1))
82+
```

0 commit comments

Comments
 (0)