Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

22-janghw0126 #91

Merged
merged 7 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions janghw0126/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

| ์ฐจ์‹œ | ๋‚ ์งœ | ๋ฌธ์ œ์œ ํ˜• | ๋งํฌ | ํ’€์ด |
|:----:|:---------:|:----:|:-----:|:----:|
| 1์ฐจ์‹œ | 2024.1.1 | Hash | <a href= "https://school.programmers.co.kr/learn/courses/30/lessons/42576">์™„์ฃผํ•˜์ง€ ๋ชปํ•œ ์„ ์ˆ˜</a> |[#4](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/4) |
| 2์ฐจ์‹œ | 2024.1.4 | Implementation | <a href= "https://www.acmicpc.net/problem/1152">๋‹จ์–ด์˜ ๊ฐœ์ˆ˜</a> |[#9](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/9) |
| 3์ฐจ์‹œ | 2024.1.7 | Implementation | <a href= "https://www.acmicpc.net/problem/1157">๋‹จ์–ด ๊ณต๋ถ€</a> |[#13](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/13) |
| 4์ฐจ์‹œ | 2024.1.10 | Implementation | <a href= "https://www.acmicpc.net/problem/2869">๋‹ฌํŒฝ์ด๋Š” ์˜ฌ๋ผ๊ฐ€๊ณ  ์‹ถ๋‹ค</a> |[#20](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/20) |
| 5์ฐจ์‹œ | 2024.1.13 | Mathematics | <a href= "https://www.acmicpc.net/problem/2581">์†Œ์ˆ˜</a> |[#24](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/24) |
| 6์ฐจ์‹œ | 2024.1.16 | Stack | <a href= "https://www.acmicpc.net/problem/28278">์Šคํƒ 2</a> |[#26](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/26) |
| 7์ฐจ์‹œ | 2024.1.19 | Stack | <a href= "https://www.acmicpc.net/problem/9012">๊ด„ํ˜ธ</a> |[#30](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/30) |
| 8์ฐจ์‹œ | 2024.1.23 | Stack | <a href= "https://www.acmicpc.net/problem/1874">์Šคํƒ ์ˆ˜์—ด</a> |[#36](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/36) |
| 9์ฐจ์‹œ | 2024.1.25 | Stack | <a href= "https://www.acmicpc.net/problem/4949">๊ท ํ˜•์žกํžŒ ์„ธ์ƒ</a> |[#40](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/40) |
| 10์ฐจ์‹œ | 2024.1.28 | Queue | <a href= "https://www.acmicpc.net/problem/10845">ํ</a> |[#42](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/42) |
| 11์ฐจ์‹œ | 2024.2.1 | Queue | <a href= "https://www.acmicpc.net/problem/1966">ํ”„๋ฆฐํ„ฐ ํ</a> |[#48](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/48) |
| 1์ฐจ์‹œ | 2024.1.1 | ํ•ด์‹œ | <a href= "https://school.programmers.co.kr/learn/courses/30/lessons/42576">์™„์ฃผํ•˜์ง€ ๋ชปํ•œ ์„ ์ˆ˜</a> |[#4](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/4) |
| 2์ฐจ์‹œ | 2024.1.4 | ๊ตฌํ˜„ | <a href= "https://www.acmicpc.net/problem/1152">๋‹จ์–ด์˜ ๊ฐœ์ˆ˜</a> |[#9](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/9) |
| 3์ฐจ์‹œ | 2024.1.7 | ๊ตฌํ˜„ | <a href= "https://www.acmicpc.net/problem/1157">๋‹จ์–ด ๊ณต๋ถ€</a> |[#13](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/13) |
| 4์ฐจ์‹œ | 2024.1.10 | ๊ตฌํ˜„ | <a href= "https://www.acmicpc.net/problem/2869">๋‹ฌํŒฝ์ด๋Š” ์˜ฌ๋ผ๊ฐ€๊ณ  ์‹ถ๋‹ค</a> |[#20](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/20) |
| 5์ฐจ์‹œ | 2024.1.13 | ์ˆ˜ํ•™ | <a href= "https://www.acmicpc.net/problem/2581">์†Œ์ˆ˜</a> |[#24](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/24) |
| 6์ฐจ์‹œ | 2024.1.16 | ์Šคํƒ | <a href= "https://www.acmicpc.net/problem/28278">์Šคํƒ 2</a> |[#26](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/26) |
| 7์ฐจ์‹œ | 2024.1.19 | ์Šคํƒ | <a href= "https://www.acmicpc.net/problem/9012">๊ด„ํ˜ธ</a> |[#30](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/30) |
| 8์ฐจ์‹œ | 2024.1.23 | ์Šคํƒ | <a href= "https://www.acmicpc.net/problem/1874">์Šคํƒ ์ˆ˜์—ด</a> |[#36](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/36) |
| 9์ฐจ์‹œ | 2024.1.25 | ์Šคํƒ | <a href= "https://www.acmicpc.net/problem/4949">๊ท ํ˜•์žกํžŒ ์„ธ์ƒ</a> |[#40](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/40) |
| 10์ฐจ์‹œ | 2024.1.28 | ํ | <a href= "https://www.acmicpc.net/problem/10845">ํ</a> |[#42](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/42) |
| 11์ฐจ์‹œ | 2024.2.1 | ํ | <a href= "https://www.acmicpc.net/problem/1966">ํ”„๋ฆฐํ„ฐ ํ</a> |[#48](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/48) |
| 12์ฐจ์‹œ | 2024.2.4 | DFS | <a href= "https://www.acmicpc.net/problem/3109">๋นต์ง‘</a> |[#53](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/53) |
| 13์ฐจ์‹œ | 2024.2.7 | DFS | <a href= "https://www.acmicpc.net/problem/2606">๋ฐ”์ด๋Ÿฌ์Šค</a> |[#57](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/57) |
| 14์ฐจ์‹œ | 2024.2.12 | Backtracking | <a href= "https://www.acmicpc.net/problem/15649">N๊ณผ M (1)</a> |[#61](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/61) |
| 15์ฐจ์‹œ | 2024.2.15 | Backtracking | <a href= "https://www.acmicpc.net/problem/15650">N๊ณผ M (2)</a> |[#65](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/65) |
| 16์ฐจ์‹œ | 2024.2.18 | Backtracking | <a href= "https://www.acmicpc.net/problem/15654">N๊ณผ M (5)</a> |[#66](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/66) |
| 17์ฐจ์‹œ | 2024.2.21 | Backtracking | <a href= "https://www.acmicpc.net/problem/15651">N๊ณผ M (3)</a> |[#72](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/72) |
| 18์ฐจ์‹œ | 2024.2.24 | Greedy | <a href= "https://www.acmicpc.net/problem/1541">์žƒ์–ด๋ฒ„๋ฆฐ ๊ด„ํ˜ธ</a> |[#77](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/77) |
| 19์ฐจ์‹œ | 2024.2.27 | Binary Search | <a href= "https://www.acmicpc.net/problem/11663">์„ ๋ถ„ ์œ„์˜ ์ </a> |[#79](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/79) |
| 20์ฐจ์‹œ | 2024.3.2 | Binary Search | <a href= "https://www.acmicpc.net/problem/1920">์ˆ˜ ์ฐพ๊ธฐ</a> |[#85](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/85) |
| 14์ฐจ์‹œ | 2024.2.12 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href= "https://www.acmicpc.net/problem/15649">N๊ณผ M (1)</a> |[#61](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/61) |
| 15์ฐจ์‹œ | 2024.2.15 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href= "https://www.acmicpc.net/problem/15650">N๊ณผ M (2)</a> |[#65](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/65) |
| 16์ฐจ์‹œ | 2024.2.18 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href= "https://www.acmicpc.net/problem/15654">N๊ณผ M (5)</a> |[#66](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/66) |
| 17์ฐจ์‹œ | 2024.2.21 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href= "https://www.acmicpc.net/problem/15651">N๊ณผ M (3)</a> |[#72](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/72) |
| 18์ฐจ์‹œ | 2024.2.24 | ๊ทธ๋ฆฌ๋”” | <a href= "https://www.acmicpc.net/problem/1541">์žƒ์–ด๋ฒ„๋ฆฐ ๊ด„ํ˜ธ</a> |[#77](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/77) |
| 19์ฐจ์‹œ | 2024.2.27 | ์ด์ง„ ํƒ์ƒ‰ | <a href= "https://www.acmicpc.net/problem/11663">์„ ๋ถ„ ์œ„์˜ ์ </a> |[#79](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/79) |
| 20์ฐจ์‹œ | 2024.3.2 | ์ด์ง„ ํƒ์ƒ‰ | <a href= "https://www.acmicpc.net/problem/1920">์ˆ˜ ์ฐพ๊ธฐ</a> |[#85](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/85) |
| 21์ฐจ์‹œ | 2024.3.5 | ์ •์ˆ˜๋ก  | <a href= "https://www.acmicpc.net/problem/17425">์•ฝ์ˆ˜์˜ ํ•ฉ</a> |[#89](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/89) |
| 22์ฐจ์‹œ | 2024.3.8 | ๋ถ„ํ•  ์ •๋ณต | <a href= "https://www.acmicpc.net/problem/1780">์ข…์ด์˜ ๊ฐœ์ˆ˜</a> |[#91](https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/91) |
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import sys
input= sys.stdin.readline
# ์žฌ๊ท€๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์ตœ๋Œ€ ๊นŠ์ด๋ฅผ ์„ค์ •ํ•ด์ค€๋‹ค.
sys.setrecursionlimit(1000)

# N์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
n=int(input())

# N๊ฐœ์˜ ์ •์ˆ˜๋“ค์„ ํ–‰๋ ฌ๋กœ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
matrix=[list(map(int,input().split())) for _ in range(n)]

# ์ข…์ด์˜ ๊ฐฏ์ˆ˜๋ฅผ ์ €์žฅํ•˜๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ์ดˆ๊ธฐํ™”ํ•œ๋‹ค.
cnt=[]

# ๋ถ„ํ•  ์ •๋ณต์„ ์‹œ์ž‘ํ•œ๋‹ค.
def divide(x,y,n):
# ํ˜„์žฌ ๊ตฌ๊ฐ„์˜ ์ƒ‰๊น”์„ ์ €์žฅํ•œ๋‹ค.
color=matrix[x][y]
# ํ˜„์žฌ ๊ตฌ๊ฐ„ ๋‚ด์˜ ๋ชจ๋“  ์ •์ˆ˜๋“ค์„ ๋ฐ˜๋ณตํ•˜๋ฉด์„œ ์ƒ‰๊น”์ด ๊ฐ™์€์ง€ ํ™•์ธํ•œ๋‹ค.
for i in range(x,x+n):
for j in range(y,y+n):
# ์ƒ‰๊น”์ด ๋‹ค๋ฅธ ๊ฒฝ์šฐ ๊ตฌ๊ฐ„์„ 9๊ฐœ๋กœ ๋‚˜๋ˆ„์–ด ์žฌ๊ท€์ ์œผ๋กœ divide ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค.
if color != matrix[i][j]:
# 9๊ตฌ๊ฐ„์œผ๋กœ ๋‚˜๋ˆ„๊ธฐ ์œ„ํ•ด a์™€ b๋ฅผ 0๋ถ€ํ„ฐ 2๊นŒ์ง€ ๋ฐ˜๋ณตํ•œ๋‹ค.
for a in range(3):
for b in range(3):
# ํ˜„์žฌ ๊ตฌ๊ฐ„์„ 9๊ฐœ์˜ ์ž‘์€ ๊ตฌ๊ฐ„์œผ๋กœ ๋ถ„ํ• ํ•˜๊ธฐ ์œ„ํ•ด divide ํ•จ์ˆ˜๋ฅผ ์žฌ๊ท€ ํ˜ธ์ถœํ•œ๋‹ค.
divide(x+(n//3)*a,y+(n//3)*b,n//3)
return
Comment on lines +16 to +29
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ—‰ ์ €๋Š” Index ๋ฅผ ๋‚˜๋ˆ„๊ณ  ๋ชซ๊ณผ ๋‚˜๋จธ์ง€๋ฅผ ๊ณ„์‚ฐํ•ด์„œ ์ข…์ด ์œ„์น˜๋ฅผ ๊ตฌํ•˜๋ฉด์„œ ์•„์ด๋””์–ด ์ฐพ๋Š”๋ฐ ์˜ค๋ž˜ ๊ฑธ๋ ธ์—ˆ๋Š”๋ฐ
2์ค‘ For๋ฌธ์œผ๋กœ 9๋ฒˆ์„ ์žฌ๊ท€ ํ˜ธ์ถœํ•˜๋„๋ก ๊ตฌํ˜„์„ ํ•˜์…จ๊ตฐ์š” !
์ƒˆ๋กœ์šด ์ฝ”๋“œ๋ฅผ ํ•˜๋‚˜ ๋” ๋ฐฐ์›Œ๊ฐ‘๋‹ˆ๋‹ค !!
๋ถ„ํ•  ์ •๋ณต ์–ด๋ ต๋„ค์š” ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค !!

# row์™€ col๋ฅผ 3๋“ฑ๋ถ„ํ•˜์—ฌ ์ด 9๋“ฑ๋ถ„
d = size // 3

# 0, 1, 2 ์ค‘ ๊ฐ€๋กœ, ์„ธ๋กœ๋กœ ๋ช‡๋ฒˆ์งธ ์นธ ๋ช‡๋ฒˆ์งธ ์œ„์น˜์— ์žˆ๋Š”์ง€ ๊ณ„์‚ฐ 
for k in range(3): 
   # 81 -> 9 -> 1 ... ์ˆœ์œผ๋กœ 9๋ฉด์œผ๋กœ ๋ถ„ํ• ํ•œ ๋’ค ๊ฐ๊ฐ ํƒ์ƒ‰
    search(r + (d*k), c , d)
    search(r + (d*k), c + d, d)
    search(r + (d*k), c + (2 * d), d)
return

# ์ƒ‰๊น”์— ๋”ฐ๋ผ์„œ ๊ฐฏ์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•ด์ค€๋‹ค.
if color==1:
cnt.append(1)
elif color==-1:
cnt.append(-1)
else:
cnt.append(0)

divide(0,0,n)
# ์ข…์ด์˜ ๊ฐฏ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
print(cnt.count(-1),cnt.count(0),cnt.count(1),sep="\n")
25 changes: 25 additions & 0 deletions janghw0126/์ •์ˆ˜๋ก /number theory_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
MAX = 1000000
# ๊ฐ ์ˆซ์ž์˜ ์•ฝ์ˆ˜์˜ ํ•ฉ์„ ์ €์žฅํ•˜๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ์„ ์–ธํ•œ๋‹ค.
dp = [1] * (MAX + 1)
# dp ๋ฆฌ์ŠคํŠธ์˜ ๋ˆ„์  ํ•ฉ์„ ์ €์žฅํ•˜๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ์„ ์–ธํ•œ๋‹ค.
s = [0] * (MAX + 1)
# 2๋ถ€ํ„ฐ MAX๊นŒ์ง€์˜ ์ˆ˜์— ๋Œ€ํ•ด ๋ฐ˜๋ณต๋ฌธ์„ ์‹คํ–‰ํ•œ๋‹ค.
for i in range(2, MAX + 1):
j = 1
# ๊ฐ ์ˆซ์ž i์— ๋Œ€ํ•ด i์˜ ๋ฐฐ์ˆ˜๋“ค์„ ์ฐพ์•„๊ฐ€๋ฉฐ dp ๋ฆฌ์ŠคํŠธ์˜ ๊ฐ’์„ ์—…๋ฐ์ดํŠธํ•œ๋‹ค.
while i * j <= MAX:
# ์˜ˆ๋ฅผ ๋“ค์–ด i๊ฐ€ 2์ผ ๊ฒฝ์šฐ dp[2], dp[4], dp[6], ... ๋“ฑ์„ i๋งŒํผ ์ฆ๊ฐ€์‹œ๊ธด๋‹ค.
dp[i * j] += i
j+=1
# 1๋ถ€ํ„ฐ MAX๊นŒ์ง€์˜ ์ˆซ์ž์— ๋Œ€ํ•ด s ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ˆ„์ ํ•ฉ์œผ๋กœ ๊ณ„์‚ฐํ•œ๋‹ค.
for i in range(1, MAX + 1):
s[i] = s[i-1] + dp[i]
iter = int(input())
ans = []
for k in range(iter):
# ์ž…๋ ฅ์œผ๋กœ ๋“ค์–ด์˜ค๋Š” iter ํšŸ์ˆ˜๋งŒํผ ๋ฐ˜๋ณต๋ฌธ์„ ์‹คํ–‰ํ•˜๋ฉด์„œ n ๊ฐ’์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
n = int(input())
# s[n] ๊ฐ’์„ ans ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€ํ•œ๋‹ค.
ans.append(s[n])
# ans ๋ฆฌ์ŠคํŠธ์˜ ๊ฐ’์„ ์ค„๋ฐ”๊ฟˆ์œผ๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ถœ๋ ฅํ•œ๋‹ค.
print('\n'.join(map(str,ans)) + '\n')