https://www.acmicpc.net/problem/4172
import math
memo = {0: 1} # x_0 = 1
inputs = []
while True:
i = int(input())
if i == -1:
break
inputs.append(i)
max_input = max(inputs) if inputs else 0
for i in range(1, max_input + 1):
floor1 = math.floor(i - math.sqrt(i))
floor2 = math.floor(math.log(i)) if i > 0 else 0
floor3 = math.floor(i * (math.sin(i) ** 2))
# 계산 및 저장
memo[i] = (memo[floor1] + memo[floor2] + memo[floor3]) % 1000000
for i in inputs:
print(memo[i])
'알고리즘 문제풀이' 카테고리의 다른 글
찐 Even Number [백준 32981] (0) | 2025.01.12 |
---|---|
도시와 비트코인[백준 31575] (0) | 2025.01.12 |
수익[백준 4097] (0) | 2025.01.09 |
무한 수열[백준 1351] (0) | 2025.01.07 |
국왕의 방문[백준 2982] (0) | 2025.01.05 |