Skip to content

Commit

Permalink
Merge pull request #257 from AlgoLeadMe/82-tgyuuAn
Browse files Browse the repository at this point in the history
82-tgyuuAn
  • Loading branch information
tgyuuAn authored Dec 1, 2024
2 parents c15a112 + 1310ccf commit 7b0570c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
4 changes: 1 addition & 3 deletions tgyuuAn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@
| 51์ฐจ์‹œ | 2024.04.07 | BFS | <a href="https://www.acmicpc.net/problem/5213">๊ณผ์™ธ๋งจ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/179
| 52์ฐจ์‹œ | 2024.05.06 | ์œ„์ƒ์ •๋ ฌ | <a href="https://www.acmicpc.net/problem/1516">๊ฒŒ์ž„ ๊ฐœ๋ฐœ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/182
| 53์ฐจ์‹œ | 2024.05.09 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href="https://www.acmicpc.net/problem/12100">2048 (Easy)</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/184
| 51์ฐจ์‹œ | 2024.04.07 | BFS | <a href="https://www.acmicpc.net/problem/5213">๊ณผ์™ธ๋งจ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/179
| 52์ฐจ์‹œ | 2024.05.06 | ์œ„์ƒ์ •๋ ฌ | <a href="https://www.acmicpc.net/problem/1516">๊ฒŒ์ž„ ๊ฐœ๋ฐœ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/182
| 53์ฐจ์‹œ | 2024.05.09 | ๋ฐฑํŠธ๋ž˜ํ‚น | <a href="https://www.acmicpc.net/problem/12100">2048 (Easy)</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/184
| 54์ฐจ์‹œ | 2024.05.14 | ๋‹ค์ต์ŠคํŠธ๋ผ | <a href="https://www.acmicpc.net/problem/9370">๋ฏธํ™•์ธ ๋„์ฐฉ์ง€</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/185
| 55์ฐจ์‹œ | 2024.05.18 | ์œ ๋‹ˆ์˜จ ํŒŒ์ธ๋“œ | <a href="https://www.acmicpc.net/problem/4195">์นœ๊ตฌ ๋„คํŠธ์›Œํฌ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/189
| 56์ฐจ์‹œ | 2024.05.18 | BFS | <a href="https://www.acmicpc.net/problem/17836">๊ณต์ฃผ๋‹˜์„ ๊ตฌํ•ด๋ผ!</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/193
Expand Down Expand Up @@ -88,4 +85,5 @@
| 79์ฐจ์‹œ | 2024.10.12 | ์ด๋ถ„ ๋งค์นญ | <a href="https://www.acmicpc.net/problem/9576">์ฑ… ๋‚˜๋ˆ ์ฃผ๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/251
| 80์ฐจ์‹œ | 2024.11.11 | ๋‹ค์ต์ŠคํŠธ๋ผ | <a href="https://www.acmicpc.net/problem/11779">์ตœ์†Œ๋น„์šฉ ๊ตฌํ•˜๊ธฐ 2</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/254
| 81์ฐจ์‹œ | 2024.11.15 | ์ด๋ถ„ ํƒ์ƒ‰ | <a href="https://www.acmicpc.net/problem/1701">Cubeeditor</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/255
| 82์ฐจ์‹œ | 2024.11.22 | ํฌ์†Œ ๋ฐฐ์—ด | <a href="https://www.acmicpc.net/problem/17435">ํ•ฉ์„ฑํ•จ์ˆ˜์™€ ์ฟผ๋ฆฌ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/257
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys

def input(): return sys.stdin.readline().rstrip()

M = int(input())
f_x = list(map(int, input().split()))

# ํฌ์†Œ ๋ฐฐ์—ด ์ดˆ๊ธฐํ™”
table = [[0] * (M + 1) for _ in range(30)]
table[0] = [0] + f_x # ์ฒซ ๋ฒˆ์งธ ๋ ˆ๋ฒจ ์ดˆ๊ธฐํ™”

# ํฌ์†Œ ๋ฐฐ์—ด ์ฑ„์šฐ๊ธฐ
for i in range(1, 30): # 2^i ๋‹จ๊ณ„๋ฅผ ๊ณ„์‚ฐ
for x in range(1, M + 1):
table[i][x] = table[i - 1][table[i - 1][x]]

# ์ฟผ๋ฆฌ ์ฒ˜๋ฆฌ
Q = int(input())
for _ in range(Q):
N, X = map(int, input().split())
# N์„ ์ด์ง„์ˆ˜๋กœ ํ‘œํ˜„ํ•ด ํ•„์š”ํ•œ ๋‹จ๊ณ„๋งŒ ์ˆ˜ํ–‰
for i in range(30):
if N & (1 << i): # i๋ฒˆ์งธ ๋น„ํŠธ๊ฐ€ 1์ด๋ผ๋ฉด
X = table[i][X]
print(X)

0 comments on commit 7b0570c

Please sign in to comment.