第16982题 单选题
对比两个计算1+2+…+n等差数列和的Python程序,其算法效率高低关系为?

程序1:

n=int(input())
s=(1+n)*n/2
print(s)

程序2:

n=int(input())
s=0
for i in range(n+1):
    s=s+i
print(s)
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析