P1035 - 不知道是哪个值错了

P1035 [NOIP2002 普及组] 级数求和

nsh_de_tt @ 2023-02-06 21:18:50

rt.以下为代码:

k = int(input())
s = 1.0
n = 2
while k < s:
    s += 1 / n
    n += 1
print(int(n))

实机测试:

输入样例1:

1

输出样例1:

2

输入样例2:

5

输出样例2:

2

by nsh_de_tt @ 2023-02-06 21:26:45

问题已找到:

while k < s:
      ^~~~~

www


|