给你一个递增序列的第一位a1,最后一位an,求有多少个序列满足:
以a1为首,an为尾
1、B(1) = A(1)
2、后面每项满足 A[j]=B[j], A(j-1) < B(j) ≤ A(j), 且bj能整除A(j) - A(j-1)。
F[ i ] [ j ] 最后一位为j 的方案数
#include<iostream> #include<cstring> #include<algorithm> #include<vector> using namespace std; const int N=50; int f[80][80] ,n ,a1,an; void sov(){ int i,j; memset(f,0,sizeof f) ; f[1][a1]=1; for(i=2;i<=N;i++) for(j=i+a1-2;j<=N;j++){ if(f[i-1][j]) for(int k=j+1;k<=N;k++){ if(k%(k-j)==0) f[i][k]+=f[i-1][j] ; } } int ans=0; for(j=1;j<=N;j++) ans+=f[j][an]; cout<<a1<<' '<<an<<' '<<ans<<endl; } signed main(){ while(cin>>a1>>an,a1||an) sov(); return 0; }
标签:Eigensequence,int,a1,11133,sov,UVA,80,include From: https://www.cnblogs.com/towboa/p/17342019.html