Http://codeforces.com/problemset/problem/414/B
Define a string as a good string when this string conforms to the Di|di+1,1<i<k-1
Given an n is the range of the elements in the string, a k is the length of the string, calculating all possible counts of the string.
I started thinking about it. Dp[i][j] I represents the length of a string, and J represents the number of strings with a length of I ending with J.
But I think it's crooked. I'm thinking of introducing all I from i-1 so that each recursion has n^2 complexity.
Read the puzzle to understand is every time with I put i+1 launch.
#include <cstdio>#include<cstring>#include<algorithm>using namespacestd;Const intMOD =1000000007;intn,k,dp[ .][ .];intMain () { while(~SCANF ("%d%d",&n,&k)) {memset (DP,0,sizeofDP); for(intI=1; i<=n;i++) dp[1][i] =1; for(intI=1; i<k;i++) { for(intj=1; j<=n;j++) { for(intp=j;p<=n;p+=j) {Dp[i+1][p] + = (dp[i][j]%MOD); Dp[i+1][P]%=MOD; } } } intAns =0; for(intI=1; i<=n;i++) {ans+=Dp[k][i]; Ans%=MOD; } printf ("%d\n", ans); }}
Before bedtime little dp-codeforce414b-dp+ a little thought