Pigeon_07 @ 2020-11-11 21:19:05
总是RE,超级迷惑
代码:
import sys
sys.setrecursionlimit(10000)
k = int(input())
i = 1
n = 1
count_list = []
def calculation():
global i
while i == n:
i += 1
count_list.append(1/i)
global total
total = sum(count_list)
global panduan
panduan()
def panduan():
global i
if total >= k:
print(total)
else:
i = 1
global n
n += 1
count_list = []
calculation()
calculation()
dalao轻喷(
by Creroity @ 2020-11-11 21:31:07
啊,一只 C++ 看了一眼,然后默默离开了……
by wmy_goes_to_thu @ 2020-11-11 21:31:54
while i == n:是怎么回事
by 星空舞涵 @ 2020-11-11 21:51:15
不知道就自己想想,自己调试啊,别啥都问,养成坏习惯
by 星空舞涵 @ 2020-11-12 06:39:10
@咕咕怪_07号 非常抱歉,昨天晚上被jc了,说了一些wyy的话,给您添麻烦了
by Pigeon_07 @ 2020-11-14 20:20:06
又胡乱修改了一下:
import math
k = int(input())
i = 1
n = 1
count_list = []
def calculation():
while i == n:
i += 1
count_list.append(1/i)
panduan()
for x in count_list:
sum += i
def panduan():
if sum >= k:
print(sum)
else:
i = 1
n += 1
count_list = []
calculation()
calculation()
by Adam_Miao @ 2023-11-24 18:41:21
orz