第一种:
from datetime import datetime
#f(x)=a0+a1x+a2x*2+a3x**3+...
def f(a,x):

p=0for i in range(0,len(a)): p=p+a[i]*((x)**i)print(p)

a=[2,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6]
x=1
begin = datetime.now() # 获取当前datetime
beg_stamp=begin.timestamp()
for i in range(0,100):

t=f(a,x)

end = datetime.now() # 获取当前datetime
end_stamp=end.timestamp() # 把datetime转换为timestamp
print(end_stamp-beg_stamp)

第二种:
from datetime import datetime
#f(x)=a0+x(a1+x(...(an-1+x(an))))
def f(a,x):

p=a[-1]for i in range(0,len(a)-1): b=list(reversed(a)) p=b[i+1]+x*pprint(p)

a=[2,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6,9,7,7,8,9,6,3,2,6,8,9,7,7,8,9,6]
x=1
begin = datetime.now() # 获取当前datetime
beg_stamp=begin.timestamp()
for i in range(0,100 ):
t=f(a,x)
end = datetime.now() # 获取当前datetime
end_stamp=end.timestamp() # 把datetime转换为timestamp
print(end_stamp-beg_stamp)

注意:按道理第一种的时间复杂度为n平方,第二种为n
但是做出来的是第一种时间更短 ,不知道为什么???试了很多次