数列的和
数列的和
http://www.nowcoder.com/questionTerminal/fe19f8a78a5148018f4be53ae9b5e11e
时间复杂度:O(M)
空间复杂度:O(1)
模拟,注意不知道何时会结束输入,使用try-except结构
import math def func(n,m): s = 0 for _ in range(m): s += n n = math.sqrt(n) return s while 1: try: line = input().split() n = int(line[0]) m = int(line[1]) print('%.2f'%(func(n,m))) except: break