狗不动了,咋写也超时,只有六十分…… 先挖个坑,等考完CCF我就来填
n=int(input())
a=list(map(int,input().split()))
a.insert(0,-1)
dp=[0]*(n+1)
dp[1]=1
data=set()
f=[[0]*(n+1) for i in range(n+1)]
an=[[0]*(n+1) for i in range(n+1)]
def inzi(i,j,data):
x=a[j]-a[i]
ans=0
if j-i==1:
data=set()
else:
data=f[i+1][j].copy()
for i in range(1,int(x**0.5)+1):
if x%i==0:
if i not in data:
data.add(i)
ans+=1
if x//i not in data:
data.add(x//i)
ans+=1
ans-=1
return data,ans
for r in range(1,n):
for i in range(1,n-r+1):
j=i+r
f[i][j]=inzi(i,j,data)[0]
an[i][j]=inzi(i,j,data)[1]
for i in range(1,n+1):
for j in range(i-1,0,-1):
dp[i]+=(dp[j]*an[j][i]%1000000007)%1000000007
print(dp[n]%1000000007)
|