http://codeforces.com/contest/415/problem/D
题意:给出n和k,求长度为k的序列个数,序列满足1 <= b1 <= b2 ......<= bk <= n且任意一个数能整除它前面的数。
思路:dp[i][j]表示长度为i最后一位是j的序列个数。那么dp[i][j] =dp[i][j] + dp[i-1][k],其中k能被j整除.
#include <stdio.h>
#include <string.h>
#define LL __int64
const int mod = 1000000007;
LL dp[2010][2010];
int main()
{
int n,k;
while(~scanf("%d %d",&n,&k))
{
memset(dp,0,sizeof(dp));
for(int i = 1; i <= n; i++)
dp[1][i] = 1;
for(int len = 1; len < k; len++)
{
for(int i = 1; i <= n; i++)
{
for(int j = 1; i*j <= n; j++)
{
dp[len+1][i*j] += dp[len][i];
dp[len+1][i*j] %= mod;
}
}
}
LL res = 0;
for(int i = 1; i <= n; i++)
{
res += dp[k][i];
res %= mod;
}
printf("%I64d\n",res);
}
return 0;
}