思路:
整除分块+dp
打表发现,按整除分块后转移方向如下图所示,上面的块的前缀转移到下面的块
代码:
#pragma GCC optimize(2)#pragma GCC optimize(3)#pragma GCC optimize(4)#includeusing namespace std;#define y1 y11Z#define se second#define pi acos(-1.0)#define LL long long//#define mp make_pair#define pb push_back#define ls rt<<1, l, m#define rs rt<<1|1, m+1, r#define ULL unsigned LL#define pll pair #define pli pair #define pii pair #define piii pair #define puu pair #define MOD(a, b) (a >= b ? a%b+b : a%b)#define pdd pair #define mem(a, b) memset(a, b, sizeof(a))#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);//headconst int N = 1e5 + 5;const int MOD = 1e9 + 7;int n, k, l[N], r[N], cnt = 0;int dp[105][N];int main() { scanf("%d %d", &n, &k); for (int x = 1, y; x <= n; x = y+1) { y = n/(n/x); l[++cnt] = x; r[cnt] = y; } for (int i = 1; i <= cnt; ++i) dp[1][i] = (dp[1][i-1] + r[i]-l[i]+1)%MOD; for (int i = 2; i <= k; ++i) { for (int j = 1; j <= cnt; ++j) { dp[i][j] = (dp[i][j-1] + (dp[i-1][cnt-j+1])*1LL*(r[j]-l[j]+1)%MOD)%MOD; } } printf("%d\n", dp[k][cnt]); return 0;}