Title Link
The definition of an array dp,dp[I [j] represents a sequence of good of length j that ends with a number I .
Easy to know dp[I][1] (1≤i≤n) for 1.
For each i,j corresponding dp[I [j], add this value to the
dp[P*i] [j+1],dp[p*i] [j+2], ...,dp[p*i [K] (P>1 and p*i≤n)
And finally, the answer is sum (dp[Q][k]), 1≤q≤n.
1#include <iostream>2#include <algorithm>3#include <map>4#include <vector>5#include <functional>6#include <string>7#include <cstring>8#include <queue>9#include <stack>Ten#include <Set> One#include <cmath> A#include <cstdio> - using namespacestd; - #defineIOS Ios_base::sync_with_stdio (False) the #defineTIE Std::cin.tie (0) - #defineMAX2 (A, B) (A>B?A:B) - #defineMAX3 (a,b,c) (a>b? ( A>C?A:C):(b>c?b:c)) -typedefLong LongLL; +typedef unsignedLong LongULL; - Const intinf=0x3f3f3f3f; + Const DoublePi=4.0*atan (1.0); A Const intMod=1000000007; at intn,k,dp[2005][2005],ans; - - intMain () - { - //while (~scanf ("%d%d", &n,&k)) -scanf"%d%d",&n,&k); inans=0; - for(intI=1; i<=n;i++){ todp[i][1]=1; + for(intj=i;j<=n;j+=i) { - for(intp=2;p <=k;p++){ thedp[j][p]+=dp[i][p-1]; * if(Dp[j][p]>mod) dp[j][p]-=MOD; $ }Panax Notoginseng } - } the for(intI=1; i<=n;i++){ +ans+=Dp[i][k]; A if(Ans>mod) ans-=MOD; the } +printf"%d\n", ans); - //} $}View Code
Codeforces 414B Mashmokh and ACM