Skip to content

Commit

Permalink
Merge pull request #29 from AlgoLeadMe/7-wnsmir
Browse files Browse the repository at this point in the history
7-wnsmir
  • Loading branch information
g0rnn authored Nov 28, 2024
2 parents 262ad54 + 4df27e1 commit b9f5e94
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions wnsmir/DP/1793ํƒ€์ผ๋ง.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
def calculate_tiling_ways():
import sys
input = sys.stdin.read
data = input().split()

max_n = 250
dp = [0] * (max_n + 1) # DP ๋ฐฐ์—ด ์ดˆ๊ธฐํ™”, 0๋ถ€ํ„ฐ 250๊นŒ์ง€ ์ €์žฅํ•  ๊ณต๊ฐ„ ์ƒ์„ฑ
dp[0], dp[1] = 1, 1 # ๊ธฐ์ € ์กฐ๊ฑด: dp[0] = 1, dp[1] = 1

# DP ์ ํ™”์‹
for i in range(2, max_n + 1):
dp[i] = dp[i-1] + dp[i-2]

results = [] # ๊ฒฐ๊ณผ ์ €์žฅ ๋ฆฌ์ŠคํŠธ
for n in map(int, data): # ์ž…๋ ฅ๋œ ๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์— ๋Œ€ํ•ด
results.append(dp[n]) # dp[n] ๊ฐ’์„ ๊ฒฐ๊ณผ ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€

# ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅ: ๊ฐ ๊ฐ’์„ ์ค„๋ฐ”๊ฟˆ์œผ๋กœ ๊ตฌ๋ถ„ํ•˜์—ฌ ์ถœ๋ ฅ
sys.stdout.write("\n".join(map(str, results)) + "\n")

if __name__ == "__main__":
calculate_tiling_ways() # ๋ฉ”์ธ ํ•จ์ˆ˜ ์‹คํ–‰

0 comments on commit b9f5e94

Please sign in to comment.