Rookie_Len @ 2022-07-21 16:51:36
def findMinIndex(k):
n = 1
while(1):
sum = 0
for i in range(1, n + 1):
sum += 1 / i
if sum > k:
return n
n += 1
k = input()
print(findMinIndex(int(k)))
by shadow_ltq @ 2022-07-21 17:09:20
@Rookie_Len 暴力肯定会TLE Sn = Sn - 1 + 1/n, 线性推即可
by Rookie_Len @ 2022-07-21 20:55:27
@shadow_ltq 谢谢回复,仔细想了一下确实做笨了。