알고리즘 문제풀이
sqrt log sin [백준 4172]
wiojfe
2025. 1. 11. 02:08
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])