3个TLE, 大家看看这很暴力吗?

P1035 [NOIP2002 普及组] 级数求和

lolaFENG @ 2022-09-21 21:19:45

k = int(input())
def sn(x):
    sum = 0
    for i in range (1, x + 1):
        a = 1 / i
        i = i + 1
        sum = sum + a
    return sum
n = 1
while 0 == 0:
    if sn(n) > k:
        print(n)
        break
    else:
        n = n +1

by Ew_Cors @ 2022-09-21 21:22:16

很暴力。


by LeTu_Jun @ 2022-09-21 21:28:09

很暴力。


by Alvin20100228 @ 2022-09-21 21:37:56

很暴力。


by xwh_Marvelous @ 2022-09-21 21:42:18

再次证明py垃圾


by lolaFENG @ 2022-09-28 14:51:02

LOL好滴~~~


by Wcx20120226 @ 2022-10-06 16:39:20

Yes,it is.


|