赛码网编程练习题_1

来源:互联网 发布:个人域名如何备案 编辑:程序博客网 时间:2024/05/20 08:26

# #题目描述:#数列的定义如下: 数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和。

import sys,mathif __name__=="__main__":    myList=[]    try:        while True:            line=sys.stdin.readline().strip()            if line == '':                break            myList.append(list(map(int,line.split())))    except:            pass    for i in xrange(len(myList)):        sumAll=float(myList[i][0])        for j in xrange(myList[i][1]-1):                print("sumAll:%f  math.sqrt:%f" %(sumAll,math.sqrt(myList[i][0])))                sumAll=sumAll+math.sqrt(myList[i][0])                myList[i][0]=math.sqrt(myList[i][0])        print("%.2f" %sumAll)